|
6 | 6 | Enter 3 for Area of Rectangle |
7 | 7 | Enter 4 for Perimeter of Rectangle |
8 | 8 | Enter 5 for Area of Circle (pi will be 3.14) |
9 | | -Enter 6 for Diameter of Circle |
| 9 | +Enter 6 for Diameter of Circle (pi will be 3.14) |
| 10 | +Enter 7 for Circumference of Circle (pi will be 3.14) |
| 11 | +Enter 8 for Area of Triangle |
| 12 | +Enter 9 for Perimeter of Triangle |
| 13 | +Enter 10 for Area of Trapezium |
10 | 14 | >>> """)) |
11 | 15 | except ValueError: |
12 | 16 | print("You have entered an invalid input. Please try again.") |
13 | 17 | else: |
14 | | - # Just giving a newline |
| 18 | + # Newline |
15 | 19 | print() |
16 | | - # For square |
| 20 | + # For Commad Lines 1 and 2 |
17 | 21 | if cmd in [1, 2]: |
18 | 22 | length = float(input("Enter length of sides of Square: ")) |
19 | | - |
20 | | - # For area of square. |
| 23 | + # For Command 1 |
21 | 24 | if cmd == 1: |
22 | 25 | print(length * length) |
23 | | - # For perimeter of square. |
| 26 | + # For Command 2 |
24 | 27 | else: |
25 | 28 | print(4 * length) |
26 | 29 | elif cmd in [3, 4]: |
27 | 30 | length = float(input("Enter length of Rectangle: ")) |
28 | 31 | breath = float(input("Enter width of Rectangle: ")) |
29 | | - # For area of Rectangle |
| 32 | + # For Command 3 |
30 | 33 | if cmd == 3: |
31 | 34 | print(length * breath) |
32 | | - # For perimeter of Rectangle |
| 35 | + # For Command 4 |
33 | 36 | else: |
34 | 37 | print(2 * (length + breath)) |
35 | | - elif cmd in [5, 6]: |
| 38 | + # For Command 5,6,7 |
| 39 | + elif cmd in [5, 6, 7]: |
36 | 40 | radius = float(input("Enter radius of circle: ")) |
| 41 | + # For Command 5 |
37 | 42 | if cmd == 5: |
38 | 43 | print(3.14 * (radius * radius)) |
| 44 | + # For Command 6 |
39 | 45 | elif cmd == 6: |
40 | | - print(3.14 * radius) |
| 46 | + print(2 * radius) |
| 47 | + # For Command 7 |
| 48 | + else: |
| 49 | + print(3.14 * (radius * 2)) |
| 50 | + # For Command 8 |
| 51 | + elif cmd == 8: |
| 52 | + base = float(input("Enter base of triangle: ")) |
| 53 | + height = float(input("Enter height of triangle: ")) |
| 54 | + print(0.5 * base * height) |
| 55 | + # For Command 9 |
| 56 | + elif cmd == 9: |
| 57 | + side = float(input("Enter side of triangle: ")) |
| 58 | + side2 = float(input("Enter second side of triangle: ")) |
| 59 | + side3 = float(input("Enter third side of triangle: ")) |
| 60 | + print(side + side2 + side3) |
| 61 | + # For Command 10,11 |
| 62 | + elif cmd in [10,11]: |
| 63 | + a = float(input("Enter base of trapezium: ")) |
| 64 | + b = float(input("Enter top length of trapezium: ")) |
| 65 | + height = float(input("Enter height of trapezim: "))] |
| 66 | + # For Command 10 |
| 67 | + if cmd == 10: |
| 68 | + print(0.5 * (a + b) * height) |
| 69 | + # For Command 11 |
| 70 | + else: |
| 71 | + width = float(input("Enter width of trapezium: ")) |
| 72 | + print((0.5 * (a + b) * height) * width) |
| 73 | + # Invalid Input Statement |
41 | 74 | else: |
42 | 75 | print("You have entered in an invalid input. Please try again.") |
0 commit comments