View Single Post
Old Feb 2nd, 2006, 11:38 AM   #1
Volkan
Newbie
 
Join Date: Feb 2006
Location: London-Uk
Posts: 7
Rep Power: 0 Volkan is on a distinguished road
Send a message via MSN to Volkan
Python area calculator

I have made a Python circle and rectangle area calculator BUT i want to make it loop back to asking for input after it has done a function so say
i chose rectangle as my shape entered my values and got my answer, after giving me the answer i want it to ask which shape to calculate again so that the user doesnt have to keep opening and closing the module.
Quote:
print "Welcome to the Area Calculator"
print "------------------------------"
print "Written By Volkan Kiziltug"
print
print "please select a shape:"
print "1 Rectangle"
print "2 Circle"

shape = input("> ")
if shape == 1:
height = input("Please enter the height: ")
width = input("please enter the width: ")
area = height*width
print "The area is", area

else:
radius = input("Please enter the radius: ")
area = 3.14*(radius**2)
print "The area is", area
i dont know how to make it ask to choose another shape again.
any help will be greatfully accepted i know you guys are pros here
i started python yesterday, been looking for some good tutorials etc. but i think im going to have to get a book.
Volkan is offline   Reply With Quote