In this Python program, we will learn how to calculate the square of a number.
Here is the source code of the program to calculate the square of a number.
Python Program to Calculate Square of a Number
# Python Program to Calculate Square of a Number
# Take Input from the User
number = float(input("Enter any number: "))
square = number * number
print("The Square of a Given Number {0} = {1}".format(number, square))
Enter any number: 5
The Square of a Given Number 5.0 = 25.0
# Python Program to Calculate Square of a Number using Exponent Operator
# Take Input from the User
number = float(input("Enter any number: "))
square = number ** 2
print("The Square of a Given Number {0} = {1}".format(number, square))
Enter any number: 6
The Square of a Given Number 6.0 = 36.0
Comments