codescracker


python

Python Program to Calculate Area of Square



« Previous Program Next Program »


Calculate Area of Square in Python

To calculate area of a square in python, you have to ask from user to enter the side length of square to calculate and print the area of that square on the output screen as shown in the program given below.

Python Programming Code to Calculate Area of Square

Following python program ask from user to enter side length of square to print area of the square:

# Python Program - Calculate Area of Square
		
while True:
	print("Enter 'x' for exit.")
	side = input("Enter side length of Square: ")
	if side == 'x':
		break
	else:
		side_length = int(side)
		area_square = side_length*side_length
		print("Area of Square =",area_square,"\n")

Here is the sample run of the above Python program shows how to calculate and print area of a square:

python calculate area 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