Python Program to find Area of a Rectangle using length and width

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.

# Python Program to find Area of a Rectangle using length and 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 find Area of a Rectangle using length and width 1

Python Program to calculate Area of a Rectangle using length and width example 2

This Python code to find the area of a rectangle is the same as above. However, we separated the python program logic using the concept of the function.

# Python Program to find Area of a Rectangle using length and width

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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.