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

Started by
2 comments, last by Potato_Tempest 22 years, 2 months ago
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


  
B00
Advertisement
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.
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.
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 ...
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---

This topic is closed to new replies.

Advertisement