How to calculate the area of a Square in Python
In this program, we will learn how to calculate the area of a square in python by user input. that is, we will ask the user to enter the length and height of the square to perform the calculation.
But before that, we first learn how to calculate the area of the square without taking an input from the user.
print('---------------------------WELCOME TO CODE WITH PETASCO BLOG----------------------')
print('=============================AREA OF A SQUARE CALCULATOR ===============================')
# taking the base from the user
#length = float(input('ENTER THE LENGTH OF THE SQUARE: '))
length = 8
# Calculating the area
area = length * length
# display the output
print('THE AREA OF THE SQUARE IS: ' + str(area))
Performing Calculation with User Input
print('---------------------------WELCOME TO CODE WITH PETASCO BLOG----------------------')
print('=============================AREA OF A SQUARE CALCULATOR ===============================')
# taking the base from the user
length = float(input('ENTER THE LENGTH OF THE SQUARE: '))
# Calculating the area
area = length * length
# display the output
print('THE AREA OF THE SQUARE IS: ' + str(area))
0 Comments