Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 14 Online
OpenStudy (anonymous):

Trying Exercise 2.10 OPT.2 Part 2 Write a list comprehension which solves the equation y = x2 +1. Your solution should print out a list of [x,y] pairs; use the domain x ∈ [−5, 5] and the range y ∈ [0, 10]. My best attempt: [(x,x*x+1) for x in range(-5,5) | (x*x+1) in range(0,10)] But does not seem to work. Anything I am missing?

OpenStudy (anonymous):

Got it. [(x,y)for x in range(-5,5) for y in range(0,11) if y == x*x+1]

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!