Write a program in python to calculate area and perimeter of square.
Answers
Answered by
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:
- Line 1: Accepts the length of the square.
- Line 2: Calculates the perimeter of the square and store the result in a variable.
- Line 3: Calculates the area of the square and store the result in a variable.
- Line 4: Displays the perimeter of the square.
- Line 5: Displays the area of the square.
See the attachment for output.
Attachments:
Answered by
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