|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
Beginner
I just started using Python today. So please excuse my "n00bish" questions.
I have: Python 2.2.2 Windows XP Home Edition. I was using this tutorial when I encountered my problem: http://www.hetland.org/python/instant-hacking.php (ctrl + f: Feedback) I was trying to do the "input" thing. I tried for the: radius = input("What is the radius?") print radius*radius*3.14 temperature = input("What is the temperature of the spam?") if temperature > 50: print "The salad is properly cooked." else: print "Cook the salad some more." # Area calculation program print "Welcome to the Area calculation program" print "---------------------------------------" # Print out the menu: print "Please select a shape:" print "1 Rectangle" print "2 Circle" # Get the user's choice: shape = input("> ") # Calculate the area: if shape == 1: height = input("Please enter the height: ") width = input("Please enter the width: ") area = height*width print "The area is", area else: radius = input("Please enter the radius: ") area = 3.14*(radius**2) print "The area is", area I got the following error: Traceback (most recent call last): File "<stdin>", line 1, in ? File "<string>", line 0 ^ SyntaxError: unexpected EOF while parsing Last edited by MasterChief : June 9th, 2003 at 07:40 PM. |
|
#2
|
|||
|
|||
|
hmm it works for me, are you sure you're properly indenting the code in the if-else sections?
|
|
#3
|
||||
|
||||
|
When you type in the values, are you putting them in quotation marks? Like this:
What is the radius? "15" input() requires you to include quotation marks to create a proper string object. You can always use raw_input which doesn't. |
|
#4
|
||||
|
||||
|
Mmmm..no?
I have to disagree with you telex4, when runing Python on my machine, when entering numbers into input(), if you add quotation marks then the number it creates a str object not an int and so you can't add, subtrect or devide it ect.
|
|
#5
|
||||
|
||||
|
Ahh, I suppose I've never used input() for integers, and it always fails on strings. The advantages of having a python shell nearby...
![]() |
|
#6
|
||||
|
||||
|
Oops?
Mmmm, I'm a lil comfused
but hey. You know if you wana delete a post click edit and then delete post at the top of the edit page.Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Beginner |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|