To calculate perimeter of rectangle in python, you have to ask from user to enter length and breadth of rectangle to calculate and print the perimeter of that rectangle as shown in the program given below.
Following python program ask from user to enter length and breadth of rectangle to find perimeter:
# Python Program - Calculate Perimeter of Rectangle while True: print("Enter 'x' for exit.") leng = input("Enter length of rectangle: ") brea = input("Enter breadth of rectangle: ") if leng == 'x': break else: length = int(leng) breadth = int(brea) perimeter = (2*length) + (2*breadth) print("Perimeter of Rectangle =", perimeter, "\n")
Here is the sample run of the above Python program shows how to calculate perimeter of rectangle:
You may also like to learn or practice the same program in other popular programming languages: