Follow us on Twitter!
I'd prefer to die standing, than to live on my knees - Che Guevara
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 32
Guests Online: 26
Members Online: 6

Registered Members: 82895
Newest Member: kevy90
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

my first python program


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 15-07-06 17:53
hi every 1 this is my first python program (for calculating areas) and was hoping could get some feedback on it and if theres a better way of doing what i did
Code
c = 0
import math
while quit != "yes":
    c = c + 1
   
    shape = raw_input("is it a circle rectangle or triangle?")
    if shape == "circle":
        rad = input("what is the radius?")
   area = math.pi * (rad**2)     
   
    elif shape == "rectangle":
   length = input("what is the length?")
   width = input("what is the width?")
   area = length*width
   if length == width:
            shape = "square"
    elif shape == "triangle":
        length = input("what is the height?")
   width = input("what is the base?")
   area = (height*base)/2
   
    else:
        print "unknown shape"
    if shape == "rectangle" or shape == "triangle" or shape == "circle" or shape == "square":
        print " the shape is %s the area is %d and this program has been run %d times " % (shape,area,c)
   
    quit = raw_input("do you want to quit? ")
import sys
sys.exit()




there should be tabs in there but dont know how to get them 2 work.



Edited by on 15-07-06 20:07