PimpHolic
08-02-2001, 11:07 PM
here is the code
# Area calculation program
print "Welcome to the Area calculation program"
print "---------------------------------------"
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
this is exaclty how it is on the website which contains the tutorial i am taking (as you can see im fairly new :) )
so my question is this
why will this not run in a terminal?
i type python area.py (area being the name of the file) and this is what i get
File "area.py", line 3
print "Welcome to the Area calculation program"
^
SyntaxError: invalid syntax
why am i getting this error? all the code seems to be fine to me..
and i wrote sort of a mini program or script like this and it worked fine
i am clueless, could someone explain what is going on?
thanks in advance
# 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
this is exaclty how it is on the website which contains the tutorial i am taking (as you can see im fairly new :) )
so my question is this
why will this not run in a terminal?
i type python area.py (area being the name of the file) and this is what i get
File "area.py", line 3
print "Welcome to the Area calculation program"
^
SyntaxError: invalid syntax
why am i getting this error? all the code seems to be fine to me..
and i wrote sort of a mini program or script like this and it worked fine
i am clueless, could someone explain what is going on?
thanks in advance