codescracker


python

Python Program to Calculate Perimeter of Square



« Previous Program Next Program »


Calculate Perimeter of Square in Python

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.

Python Programming Code to Calculate Perimeter of Square

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:

python calculate perimeter of square

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test