A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Does anyone else get an error message when using this in idle? The example is giving in the reading assignment but it doesn't work and I'm not understanding why. I get the error message when I enter: plusTen = number + 10
print ("Please give me a number:",)
response = raw_input()
number = int(response)
plusTen = number + 10
print ("If we add 10 to your number, we get " + str(plusTen))
anonymous
 5 years ago
Does anyone else get an error message when using this in idle? The example is giving in the reading assignment but it doesn't work and I'm not understanding why. I get the error message when I enter: plusTen = number + 10 print ("Please give me a number:",) response = raw_input() number = int(response) plusTen = number + 10 print ("If we add 10 to your number, we get " + str(plusTen))

This Question is Closed

nowhereman
 5 years ago
Best ResponseYou've already chosen the best response.0Observe that there is a different syntax for print in python2 and python3. Also the userinput in your case must be a legal number. If you enter "plusTen = number + 10" that is not a number and an exception is thrown. You should catch that in the code.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0i understand the "type" error. the reading says that to fix it you need to use 'int' and 'str'. the modified example in the reading gives me the error message, though, it does not work with the fixes it recommends.

nowhereman
 5 years ago
Best ResponseYou've already chosen the best response.0As long as you don't input anything which can be converted to an integer, you will get an error.

carlsmith
 5 years ago
Best ResponseYou've already chosen the best response.0It's a bit odd to be printing a tuple as a prompt before an input function call? For Python2, it'd be a little more sane to do: response = raw_input('Please give me a number: ') number = int(response) # will crash if this conversion isn't doable plusTen = number + 10 print 'If we add ten to your number, we get ' + str(plusTen) For Python3: response = input('Please give me a number: ') number = int(response) # can crash still plusTen = number + 10 print('If we add ten to your number, we get', plusTen) Dunno if that helps at all.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.