Write a Python program that calculates the area of a rectangle. Your program should define a function called `calculate_area` that accepts the length and width of the rectangle as parameters. The function should return the calculated area. In the main program, prompt the user to enter the length and width of the rectangle, call the `calculate_area` function, and print the result.
Declaring functions
Calculate rectangle area with user input
Report a typo
Sample Input 1:
5
3Sample Output 1:
15.0Sample Input 2:
2.5
4Sample Output 2:
10.0Write a program in Python 3
# Import necessary libraries
# Function to calculate the area of a rectangle
def calculate_area(length, width):
# Your code here
# Main program
def main():
length = float(input())
width = float(input())
area = calculate_area(length, width)
print(area)
if __name__ == "__main__":
main()
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.