Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

halkazi

  • 3 years ago

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?

  • This Question is Closed
  1. halkazi
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  2. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy