;

Python Program to Calculate the Square of a Number


Tutorialsrack 25/04/2020 Python

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.

Program 1: Python Program to Calculate 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))
Output

Enter any number: 5

The Square of a Given Number 5.0  = 25.0

Program 2: Python Program to Calculate Square of a Number using Exponent Operator

Python Program to Calculate Square of a Number using Exponent Operator
# 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))

Output

Enter any number: 6

The Square of a Given Number 6.0  = 36.0


Related Posts



Comments

Recent Posts
Tags