# Python program to find the area of square

In this python tutorial, you will learn about the Python program to find the area of square and, also we will check:

• How to find the area of square in Python
• Python program to find the area of square by getting input from a user
• Python program to find the area of a square using function
• How to find area and perimeter of a square in Python

## Python program to find the area of square

Let see python program to find the area of square

• In this example, we will define the height of any one side of the square as “side”.
• Now, calculate the area of the square by using the formula as Area = side*side
• At last, print the area of the square to get the output.

Example:

``````side = 6
Area = side*side
print("Area of the square="+str(Area))``````

You can refer to the below screenshot to see the output for the python program to find the area of a square.

The above code we can use to find the area of square in Python.

## Python program to find area of a square by getting input from a user

Here, we will see python program to find the area of the square by getting input from a user

• Firstly, we will take input from the user for the side value of the square using the input() method.
• Now, calculate the area of the square by using the formula as Area = side*side
• At last, print the area of the square to get the output.

Example:

``````side = int(input("Enter the side:"))
Area = side*side
print("Area of the square="+str(Area))``````

You can refer to the below screenshot to see the output for the python program to find the area of the square by getting input from a user. Python program to find the area of the square by getting input from a user

This is the Python program to find area of a square by getting input from a user.

Also read, How to calculate area of a circle in Python?

## Python program to find area of a square using function

Now, we will see python program to find the area of a square using function

• Firstly, we will define a function with arguments using def keywords.
• Now, we will calculate the area of a square inside the function by using the formula Area = side*side.
• Here, the side=12 is defined and the value is passed to the function argument.
• At last, print the area of a square to get the output.

Example:

``````def Areaofsquare(side):
Area = side*side
return Area
side = 12
print(Areaofsquare(side))``````

You can refer to the below screenshot to see the output for the python program to find the area of a square using function. Python program to find the area of a square using function

The above code is to find area of a square using function in Python.

Check out, How to calculate simple interest in Python?

## Python program to find area and perimeter of a square

Let’s see python program to find area and perimeter of a square.

• Firstly, we will take input from the user for the side value of the square using the input() method.
• Now, calculate the area of the square by using the formula Area = s*s.
• Next, we will calculate the perimeter of a square by using the formula Perimeter=4*s
• At last, print the area and perimeter of the square to get the output.

Example:

``````s=int(input("Enter the side : "))
Area=s*s
Perimeter=4*s
print("Area of rectangle : ",Area)
print("Perimeter of rectangle : ",Perimeter)``````

You can refer to the below screenshot to see the output for the python program to find area and perimeter of a square.