#menu
print "Area Caculation Program"
print "-----------------------"
print
print "Select a shape"
print "1. Rectangle"
print "2. Circle"
print "3. Triangle"
print "4. Trapazoid"
shape = input()
#get area
if shape == 1:
print "Area of a Rectangle
print "---------------"
print
length = input("Please input length")
width = input("Please input width")
area = length*width
print "the area is", area
elif shape == 2
print "Area of a Circle
print "---------------"
print
radius = input("Please input the radius")
area = (3.14*radius)radius
print "The area is", area
elif shape == 3
print "Area of a Triangle"
print "------------------"
print
length = input("Please input length")
width = input("Please input width")
area = .5(length*width)
print "The area is", area
elif shape == 4
print "Area of a Trapazoid"
print "-------------------"
print
length = input("Please input length")
b = input("Please input the first width")
c = input("Please input the second width")
area = .5length(b+c)
print "The area is", area
Cant get this program to work! I dont know whats wrong!
Cant get this program to work! I dont know whats wrong!
It''s in python, by the way:
I don''t know python, but have some general suggestions:
1) Do you get runtime errors or just nothing? I''m assuming this is a shell, and thus is not compiled.
2) Do you see the first print statements? If so, can you enter a number?
3) If you can enter a number, print out the value right after the input statement to see what you got. Does it look right? Is it a number, or a string?
4) Put print statements at other places as debug aids, even if just to say "got to line 20" or some such.
Good luck.
1) Do you get runtime errors or just nothing? I''m assuming this is a shell, and thus is not compiled.
2) Do you see the first print statements? If so, can you enter a number?
3) If you can enter a number, print out the value right after the input statement to see what you got. Does it look right? Is it a number, or a string?
4) Put print statements at other places as debug aids, even if just to say "got to line 20" or some such.
Good luck.
I don''t know the language but has it got something to do with this:
if shape == 1:
Are you sure that colon is supposed to be there. It''s not on any of the other conditional statements.
if shape == 1:
Are you sure that colon is supposed to be there. It''s not on any of the other conditional statements.
It''s your first block of prints. They should be to the far left and should stay there.
Your print statements in the form they''re in now means they''re nested, but they shouldn''t. So jst press backspace...
And, don''t just keep pressing spacebar, use tab. But if you do know to use tab, online, please use ...
Your print statements in the form they''re in now means they''re nested, but they shouldn''t. So jst press backspace...
And, don''t just keep pressing spacebar, use tab. But if you do know to use tab, online, please use ...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement