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