Archived

This topic is now archived and is closed to further replies.

Cant get this program to work! I dont know whats wrong!

This topic is 6012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Cant get this program to work! I dont know whats wrong! It''s in python, by the way:
  #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 

Share on other sites
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.

Share on other sites
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.

Share on other sites
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 ...

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 10
• 9
• 9
• 10
• Forum Statistics

• Total Topics
631751
• Total Posts
3002085
×