Articles

Program to find square of a number in Python

Program to find square of a number in Python


In this python program guide, we will learn to write:

  • program to find square of a number in python

Program to find sqaure in Python

Here we will accept an input from user. We will use ** to calculate square, store the output in a variable and finally print the value of the variable.

 

Please check our video tutorial on program to find square of a number in python:

 

 

Given below we write a python program to find the square of a number:

# Owner : TutorialsInhand Author : Devjeet Roy

number = int(input("Enter the number: "))

sq = number ** 2

print("The squared value is:",sq)

The output of the python code to find square of a number is as follows:

 

PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
Enter the number: 4
The squared value is: 16

Few important points about this program:

1. In Python, we use the "**" operator to do calculations using exponent.

2. The number before "**" is the base, and the number after the operator is the exponent.

 

write a python program to find the square of a number snapshot:

write a python program to find the square of a number

This wraps up our session on python code to find square of a number or program to find square of a number in python.


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :    Published Date : Nov 13,2022  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!