Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Hi I have a question on Pract Quiz1 #5. I posted the question and the code in the pastebin below. Thanks http://pastebin.com/YwLYPwPQ

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
*
raw_input() returns a string.
# The following code contains two semantic errors. Correct it so that it reads in integers until the user enters -1, and then prints the sum of the integers (8 points) def getLines(): inputs = [] while True: line = raw_input('Enter a positive integer, -1 to quit: ') # I have casted the value to int here if int(line) == -1: break # I have casted the value to int here. You can either put it here or in the for loop to convert them while adding them inputs.append(int(line)) # There is no return value in the original code. This should fix it! return inputs total = 0 for e in getLines(): total += e print total

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Thanks everyone. I got it now!

Not the answer you are looking for?

Search for more explanations.

Ask your own question