To calculate area of rectangle in python, you have to ask from user to enter length and breadth of rectangle to calculate and print area of that rectangle on the output screen as shown in the program given below.
Following python program ask from user to enter length and breadth of rectangle to calculate area:
# Python Program - Calculate Area of Rectangle print("Enter 'x' for exit."); leng = input("Enter length of Rectangle: "); if leng == 'x': exit(); else: brea = input("Enter breadth of Rectangle: "); length = int(leng); breadth = int(brea); area = length*breadth; print("\nArea of Rectangle =",area);
Here is the sample run of the above Python program shows how to calculate area of rectangle:
Now enter length and breadth of that rectangle whose area you are going to find out using the above program. After entering length say 7 and breadth say 5, press enter key to see the area as shown in the below sample output:
Here is the same program with run on python shell:
Program Video with Compile and Run
You may also like to learn or practice the same program in other popular programming languages: