1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help, Invalid Syntax

Discussion in 'Programming' started by Ge'ez, Aug 25, 2006.

  1. Ge'ez

    Ge'ez New Member

    Joined:
    Aug 24, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Underground in Ethiopia
    Sorry if this is the wrong section to post this.

    I'm starting to learn Python as my first program and I'm trying to do the exercise at the bottom of this tutorial page (http://www.honors.montana.edu/~jjc/easytut/easytut/node9.html)

    Here's what I have but I keep getting an error ("There's an error in your program:invalid syntax") when I try to Run>Run Module.

    Code:
    def print_options():
        print "Options:"
        print "'p' print options"
        print "'r' Area of a rectangle"
        print "'s' Area of a square"
        print "'c' Area of a circle"
        print "'q' quit the program"
    
    def rec_area(l,w):
        rarea = l*w
        return rarea
    def squ_area(l,w):
        sarea = l*w
    def cir_area(r):
        carea = 3.14*r**2
    
    choice = "p"
    while choice != "q":
            if choice == "r":
                l = input ("Length:")
                w = input ("Width:")
                print "The area of this rectangle=", rec_area(l,w)
            elif choice == "s":
                l = input ("Length:")
                w = input ("Width:")
                print "The area of this square=", def squ_area (l,w}
            elif choice == "c":
                r = input ("Radius:")
                print "The area of this circle=", def cir_area(r)
            elif choice != "q":
                print_options()
            choice = raw_input("Option:")
    
     
  2. TEJUS

    TEJUS New Member

    Joined:
    Aug 6, 2006
    Messages:
    11
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    STUDENT
    Location:
    IN KERALA,KOLLAM
    sorry,i think this is not the right place for u to post such posts.if i have learnt python then surely i
    was going to help u .Don't worry ,if u have any doubts in C (not C++) then ask me.
     

Share This Page