Computer Science, asked by panchasaraheena1, 3 days ago

Write a program in python to calculate area and perimeter of square.

Answers

Answered by anindyaadhikari13
15

Solution:

The given problem is solved in Python.

length = float(input('Enter the length of the square: '))

perimeter = 4 * length

area = length * length

print('Perimeter of the square is',perimeter,'unit.')

print('Area of the square is',area,'square unit.')

Explanation:

  1. Line 1: Accepts the length of the square.
  2. Line 2: Calculates the perimeter of the square and store the result in a variable.
  3. Line 3: Calculates the area of the square and store the result in a variable.
  4. Line 4: Displays the perimeter of the square.
  5. Line 5: Displays the area of the square.

See the attachment for output.

Attachments:
Answered by kamalrajatjoshi94
2

Answer:

side=float(input("Enter the side of square:"))

area=side*side

peri=4*side

print(f"Area of square:{area}")

print(f"Perimeter of square:{peri}")

Attachments:
Similar questions