Computer Science, asked by Yupendran, 1 year ago

python program to find the area of a square​

Answers

Answered by Pratikkumar772845
28

Answer:

To calculate area of a square in python, you have to ask from user to enter the side length of square to calculate and print the area of that square on the output screen as shown in the program given below.

Python Programming Code to Calculate Area of Square

Following python program ask from user to enter side length of square to print area of the square:

# Python Program - Calculate Area of Square

print("Enter 'x' for exit.");

side = input("Enter side length of Square: ");

if side == 'x':

exit();

else:

side_length = int(side);

area_square = side_length*side_length;

print("\nArea of Square =",

Tnx!!!!

Answered by AskewTronics
10

Python program and the output of the program is listed below :

Output :

If the user input as 3, then the output is 9.

If the user input as 4, then the output is 16.

Explanation:

side =float(input("Enter the side of a square to prints the area: "))#Take the input from the user.

print("The area of a Square is",side*side)#print the area of a Square.

Code Explanation :

  • The above code is in python, in which the first line is used to take the input from the user after instructing the user for the input and store it on the side variable after converting it into float type value.
  • Then the area is printed with the help of a print statement after calculating the area of the square with the help of the formula of an area of a square.

Learn More :

  • Python : https://brainly.in/question/14689905
Similar questions