-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea_of_two_rectangle.py
More file actions
31 lines (25 loc) · 1.17 KB
/
area_of_two_rectangle.py
File metadata and controls
31 lines (25 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# The area of rectangle
# asking the user to input the length and the width of the rectangle
# for two rectangles and calculate which one of them have the greater area
# or if they're the same
# First asking the user to enter the length and width of first rectangle
rec1_length = float(input('Enter the length of 1 rectangle: '))
rec1_width = float(input('Enter the width of 1 rectangle: '))
# Second calculating the area of the first rectangle
rec1_area = rec1_length * rec1_width
print('The area of 1 rectangle is: %.2f' % (rec1_area))
print('\n')
# Third asking the user to input the length and width of 2 rectangle
rec2_length = float(input('Enter the length of 2 rectangle: '))
rec2_width = float(input('Enter the width of 2 rectangle: '))
# Fourth calculating the area of 2 rectangle
rec2_area = rec2_length * rec2_width
print('The area of 2 rectangle is: %.2f' % (rec2_area))
print('\n')
# finding which rectangle have the greatest area
if rec1_area > rec2_area:
print('Rectangle 1 has the greats area: %.2f' % (rec1_area))
elif rec2_area > rec1_area:
print('Rectangle 2 has the greats area: %.2f' % (rec2_area))
elif rec2_area == rec1_area:
print('They are equal......')