In this python program, we discuss finding the Square of a number in python, and in This program, we use the arithmetic Operators and Function.
Python program to find the Square of a Number
In this python program, we use the arithmetic Operators to find the Square of a number.
Example
number = float(input(" Please Enter any numeric Value : "))
square = number * number
print("The Square of a Given Number {0} = {1}".format(number, square))
Here Is the Output of a program
Please Enter any numeric Value : 8
The Square of a Given Number 8.0 = 64.0
Python Program to find Square of a Number using the Exponent operator.
In this python program, we find the square of a number using the Exponent operator.
number = float(input(" Please Enter any numeric Value : "))
square = number ** 2
print("The Square of a Given Number {0} = {1}".format(number, square))
Here is the output of this program.
Please Enter any numeric Value : 16
The Square of a Given Number 16.0 = 256.0
write a Python Program to find Square of a Number using Functions
In this program we find Python Program to find Square of a Number using Functions and calculate the square of a number.
def square(num):
return num * num
number = float(input(" Please Enter any numeric Value : "))
sqre = square(number)
print("The Square of a Given Number {0} = {1}".format(number, sqre))
Here is the output of a program.
def square(num):
return num * num
number = float(input(" Please Enter any numeric Value : "))
sqre = square(number)
print("The Square of a Given Number {0} = {1}".format(number, sqre))