Timothy S. answered • 11/07/13

Tutor

5
(9)
Will help you LOVE math, science, and computing!

for loops and dictionaries are your best friends in the world

#declare y as a dictionary to allow for negative indexing

y = {}

#calculate all y

for x1 in range(-12,13):

#add a new dictionary to the main dictionary at the key of x1's current value to allow multidimensional space

y[x1] = {}

for x2 in range(-12,13):

y[x1][x2] = 2*x1*x1 + x2*x2

#print all y (could be done in line with calculation for efficiency but done separately for understanding

for x1 in range(-12, 13):

for x2 in range(-12,13):

print "y[%d][%d] = %d" %(x1, x2, y[x1][x2])

y = {}

#calculate all y

for x1 in range(-12,13):

#add a new dictionary to the main dictionary at the key of x1's current value to allow multidimensional space

y[x1] = {}

for x2 in range(-12,13):

y[x1][x2] = 2*x1*x1 + x2*x2

#print all y (could be done in line with calculation for efficiency but done separately for understanding

for x1 in range(-12, 13):

for x2 in range(-12,13):

print "y[%d][%d] = %d" %(x1, x2, y[x1][x2])

Sam B.

Hi I'm trying to implement the learning from examples algorithm in fuzzy logic using the function and limits i gave in Python

Report

11/11/13

Timothy S.

11/07/13