|
1 | 1 | '''Python Projects: Calculate the areas of polygons.
|
2 |
| -ToDo: |
3 | 2 | => Display user the options for selecting area of required polygon.
|
4 | 3 | => As per the user selection, ask him the required parameters.
|
5 | 4 | => Show the area of required polygons.
|
6 |
| - => Write functions to calculate the area of each polygon. |
7 |
| - => Validate the user input. |
| 5 | + => Write separate functions to calculate the area of each polygon. |
| 6 | + => Validate the user input. |
8 | 7 | '''
|
9 | 8 | import helper
|
10 | 9 | while True:
|
|
40 | 39 | f"The area of square with side {side}: {area:.2f}")
|
41 | 40 |
|
42 | 41 | elif user_option == '4':
|
43 |
| - width = input("Enter height, width (eg. 5, 7): ").split(', ') |
| 42 | + height, width = input( |
| 43 | + "Enter height, width (eg. 5, 7): ").split(', ') |
44 | 44 | area = helper.rectangle_area(height, width)
|
45 | 45 | print(
|
46 | 46 | f"The area of rectangle with height {height}, width {width}: {area:.2f}")
|
|
52 | 52 | print(
|
53 | 53 | f"The area of trapezium with side1 {side1}, side2 {side2}, height {height}: {area:.2f}")
|
54 | 54 |
|
55 |
| - elif user_option == '5': |
56 |
| - side1, side2, height = input( |
57 |
| - "Enter side1, side2, height (eg. 5, 7, 9): ").split(', ') |
58 |
| - area = helper.trapezium_area(side1, side2, height) |
| 55 | + elif user_option == '6': |
| 56 | + base, height = input("Enter base, height (eg. 5, 7): ").split(', ') |
| 57 | + area = helper.parallelogram_area(base, height) |
59 | 58 | print(
|
60 |
| - f"The area of trapezium with side1 {side1}, side2 {side2}, height {height}: {area:.2f}") |
| 59 | + f"The area of parallelogram with base {base} and height {height}: {area:.2f}") |
| 60 | + |
| 61 | + elif user_option == '7': |
| 62 | + diagonal1, diagonal2 = input( |
| 63 | + "Enter diagonal1, diagonal2 (eg. 5, 7): ").split(', ') |
| 64 | + area = helper.rhombus_area(diagonal1, diagonal2) |
| 65 | + print( |
| 66 | + f"The area of rhombus with diagonal1 {diagonal1} and diagonal2 {diagonal2}: {area:.2f}") |
| 67 | + |
| 68 | + elif user_option == '8': |
| 69 | + radius = input("Enter radius(eg. 5): ") |
| 70 | + area = helper.circle_area(radius) |
| 71 | + print( |
| 72 | + f"The area of circle with radius {radius}: {area:.2f}") |
61 | 73 |
|
62 | 74 | is_continue = input("Do you want to continue?(yes/no): ")
|
63 | 75 |
|
|
0 commit comments