File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
-
1
+ """
2
+ 2. Areas of Rectangles
3
+ The area of a rectangle is the rectangles length times its width.
4
+ Write a program that asks for the length and width of two rectangles.
5
+ The program should tell the user which rectangle has the greater area,
6
+ or if the areas are the same.
7
+ Reference:
8
+ (1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3
9
+ (2) https://youtu.be/7be9HlHRB-E
10
+ """
11
+ # Get User Input(the length and width of two rectangles.)
12
+ # Convert User input to float
13
+ rectangle1_length = float (input ("Please Enter the length of Rectangle 1 : " ))
14
+ rectangle1_width = float (input ("Please Enter the Width of Rectangle 1 : " ))
15
+ rectangle2_length = float (input ("Please Enter the length of Rectangle 2 : " ))
16
+ rectangle2_width = float (input ("Please Enter the Width of Rectangle 2 : " ))
17
+ # Compute Area of Rectangle for both
18
+ rectangle1_area = rectangle1_length * rectangle1_width
19
+ rectangle2_area = rectangle2_length * rectangle2_width
20
+ # check all the conditions
21
+ if rectangle1_area > rectangle2_area :
22
+ print ("Rectangle 1 is Bigger than Rectangle 2" )
23
+ elif rectangle2_area > rectangle1_area :
24
+ print ("Rectangle 2 is Bigger than Rectangle 1" )
25
+ else :
26
+ print ("the areas are the same" )
You can’t perform that action at this time.
0 commit comments