Write Python Program to find Area of a Rectangle using length and width with a practical example.
Python Program to find Area of a Rectangle using length and width example 1
This Python program allows user to enter the length and width of a rectangle. Using those two values, it finds the area of a rectangle. If we know the length & width of a rectangle. The mathematical formula to calculate the area of a rectangle is: Area = Length * Width.
length = float(input('Please Enter the Length of a Triangle: '))
width = float(input('Please Enter the Width of a Triangle: '))
# calculate the area
area = length * width
print("The Area of a Rectangle using", length, "and", width, " = ", area)

Python Program to calculate Area of a Rectangle using length and width example 2
This Python code to find the area is the same as above. However, we separated the python program logic using the concept of the function with two parameters and it returns a value.
def area_of_Rectangle(length, width):
return length * width
length = float(input('Please Enter the Length of a Triangle: '))
width = float(input('Please Enter the Width of a Triangle: '))
# calculate the area of a Rectangle
area = area_of_Rectangle(length, width)
print("The Area of a Rectangle using", length, "and", width, " = ", area)
Please Enter the Length of a Triangle: 125
Please Enter the Width of a Triangle: 65
The Area of a Rectangle using 125.0 and 65.0 = 8125.0