Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

5 points status: not submitted take your code from the rectangle exerci…

Question

5 points status: not submitted take your code from the rectangle exercise in the last lesson, and change it so that the user gets to type the length and width of the rectangle. as with the exercise in the last lesson, you will need two variables, one called length and one called width. in this exercise, you will need to make a call to input for each of these variables. then, write some mathematical expressions in print statements to display the area and perimeter of the rectangle. an example call for input should look like this: what is the length?: 10 what is the width?: 5 with the previous values, the following output should be given: area: 50 perimeter: 30 you should be printing a string and a variable on the same line each time. tip: youll need to make use of the int() method.

Explanation:

Step1: Get user input for length

length = int(input("What is the length? "))

Step2: Get user input for width

width = int(input("What is the width? "))

Step3: Calculate area

area = length * width

Step4: Calculate perimeter

perimeter = 2 * (length + width)

Step5: Print area

print("Area:", area)

Step6: Print perimeter

print("Perimeter:", perimeter)

Answer:

The code above achieves the described functionality.