Oct-09-2017, 03:06 AM
I need to write this simple code for my python class. It has stumped me and I cant find any help through google searching.
My problem is, when I try to select an option from my menu, the menu gets displayed again. Any help would be appreciated!
My problem is, when I try to select an option from my menu, the menu gets displayed again. Any help would be appreciated!
import math a = None def Main(): while True: choice = input( """ Welcome to my calculation program! please choose from the following options. 1. Find the area of a circle 2. Find the circumfrence of a circle 3. Find the area of a rectangle 4. find the perimeter of a rectangle 5. Exit the program """ ) if choice == 1: CircleArea() elif choice == 2: CircleCircumf() elif choice == 3: RectangleArea() elif choice == 4: RectangleParam() elif choice == 5: exit def CircleArea(): radius = input("\nPlease input the radius of the circle") area = math.pi*r*r print ("\nThe area of your circle is ", area) while True: choice = input ("Would you like to return to the main menu? y/n") if choice == y: Main() elif choice == n: exit def CircleCircumf(): radius = input("\nPlease input the radius of the circle") circumf = 2 * math.pi * radius print ("\nThe circumference of the circle is", circumf) while True: choice = input ("Would you like to return to the main menu? y/n") if choice == y: Main() elif choice == n: exit def RectangleArea(): width = input("\nHow wide is the rectangle?") height = input("\nHow high is the rectange?") area = width * height print("The area of the rectangle is", area) while True: choice = input ("Would you like to return to the main menu? y/n") if choice == y: Main() elif choice == n: exit def RectangleParam(): width = input("\nHow wide is the rectangle?") height = input("\nHow high is the rectange?") param = width + width + height + height print("\nThe perimeter of the rectangle is", param) while True: choice = input ("Would you like to return to the main menu? y/n") if choice == y: Main() elif choice == n: exit Main()