This document provides a practical exercise to write a program that calculates the area and perimeter of a square based on user input for the side length. The area is calculated using the formula s^2, while the perimeter is calculated using 4s. The program outputs the results formatted to two decimal places.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
10 views1 page
Practical-03 Exercise 5
This document provides a practical exercise to write a program that calculates the area and perimeter of a square based on user input for the side length. The area is calculated using the formula s^2, while the perimeter is calculated using 4s. The program outputs the results formatted to two decimal places.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Practical No: 03
Exercise 5: Write a program to calculate area and perimeter of the
square.
side = float(input("Enter the side length of the square: "))
area = side**2 #Area=s^2 perimeter = 4 * side #Perimeter=4s print(f"The area of the square is {area:.2f}") print(f"The perimeter of the square is {perimeter:.2f}")