diff options
| author | mo khan <mo@mokhan.ca> | 2025-01-12 18:41:39 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-01-12 18:41:39 -0700 |
| commit | 3eb0794fc4d0a1760c8bf439f55e28f2c0ccfa0e (patch) | |
| tree | 839daa8b5d5f617cc2f8b018e105da49a4454a8c | |
| parent | f9b7f6b5fc4e463611e1d6c5d8d8b7e73157ae93 (diff) | |
Complete section 4 of project 2
| -rwxr-xr-x | projects/2/prog4.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/projects/2/prog4.py b/projects/2/prog4.py index dd0f49e..cc70d4e 100755 --- a/projects/2/prog4.py +++ b/projects/2/prog4.py @@ -5,3 +5,71 @@ Program author: mo khan ID: 3431709 Program 4 - Functions """) + +def menu(): + print(""" + CALCULATIONS MENU + + 1) AREA (SQUARE) + 2) AREA (RECTANGLE) + 3) AREA (CIRCLE) + 4) PERIMETER (SQUARE) + 5) PERIMETER (RECTANGLE) + 6) PERIMETER (CIRCLE) + 7) EXIT + """) + + return int(input("INPUT MENU CHOICE (1,2,3,4,5,6 OR 7)? ")) + +def area_square(): + print("YOU HAVE CHOSEN AREA (SQUARE)") + length = int(input("INPUT LENGTH? ")) + print("AREA IS {}".format(length*length)) + +def area_rectangle(): + print("YOU HAVE CHOSEN AREA (RECTANGLE)") + width = int(input("INPUT WIDTH? ")) + length = int(input("INPUT LENGTH? ")) + print("AREA IS {}".format(length*width)) + +def area_circle(): + print("YOU HAVE CHOSEN AREA (CIRCLE)") + radius = int(input("INPUT RADIUS? ")) + print("AREA IS {}".format(3.4* radius**2)) + +def perimeter_square(): + print("YOU HAVE CHOSEN PERIMETER (SQUARE)") + length = int(input("INPUT LENGTH? ")) + print("PERIMETER IS {}".format(4*length)) + +def perimeter_rectangle(): + print("YOU HAVE CHOSEN PERIMETER (RECTANGLE)") + width = int(input("INPUT WIDTH? ")) + length = int(input("INPUT LENGTH? ")) + print("PERIMETER IS {}".format(2*length+2*width)) + +def perimeter_circle(): + print("YOU HAVE CHOSEN PERIMETER (CIRCLE)") + radius = int(input("INPUT RADIUS? ")) + print("PERIMETER IS {}".format(2*3.14*radius)) + +def main(): + choice = 0 + while choice != 7: + if choice == 1: + area_square() + elif choice == 2: + area_rectangle() + elif choice == 3: + area_circle() + elif choice == 4: + perimeter_square() + elif choice == 5: + perimeter_rectangle() + elif choice == 6: + perimeter_circle() + elif choice == 7: + exit(0) + choice = menu(); + +main() |
