Hey guys new to python and programming in general.. Got this simple area calculator program but have a few questions on it. Once you do a calculation it quits.. I would like it to ask to continue to another calculation or quit but I don't know how to re-call the program. Are there ways like functions or blocks I could put the code in to call it to run whenever I want like run this part again for another calculation.
#-------------------
# PRINT OUT THE MENU
print "Please select a shape"
print "1 - Rectangle"
print "2 - Triangle"
print "3 - Circle"
#----------------
# GETS USER INPUT
shape = input(">> ")
#-----------------
# CALCULATING AREA
# RECTANGLE
if shape == 1:
height = input("Enter the Height: ")
width = input("Enter the Width: ")
area = height*width
print "The area is ", area
# TRIANGLE
elif shape == 2:
base = input("Enter Base Value: ")
height = input("Enter Height: ")
area = .5*base*height
print "The area is ", area
# CIRCLE
else:
radius = input("Enter the Radius: ")
area = 3.14*(radius**2)
print "The area is ", areaI need a way to block sections of code to run when I call for them but not sure how to do this.. Here is the source let me know if you have any questions about what I am asking... thanks.
print "Area Calculation Program"
print "------------------------"
print
print
#-------------------
# PRINT OUT THE MENU
print "Please select a shape"
print "1 - Rectangle"
print "2 - Triangle"
print "3 - Circle"
#----------------
# GETS USER INPUT
shape = input(">> ")
#-----------------
# CALCULATING AREA
# RECTANGLE
if shape == 1:
height = input("Enter the Height: ")
width = input("Enter the Width: ")
area = height*width
print "The area is ", area
# TRIANGLE
elif shape == 2:
base = input("Enter Base Value: ")
height = input("Enter Height: ")
area = .5*base*height
print "The area is ", area
# CIRCLE
else:
radius = input("Enter the Radius: ")
area = 3.14*(radius**2)
print "The area is ", area