Sunday, September 28, 2025

Python Program Collection 02 - to display area, perimeter of rectangle, square, circle, triangle, area of 4 walls

 



Python Program Collection 02 - to display area, perimeter of rectangle, square, circle, triangle, area of 4 walls

15. Display area of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

area = length * breadth

print(f"Area of rectangle with length {length} and breadth {breadth} is {area}")

 

16. Display area of square.

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

area = side ** 2

print(f"Area of square with side {side} is {area}")

 

17. Display area of circle.

radius = float(input("Enter the radius of the circle: "))

area = 22 / 7 * (radius ** 2)

print(f"Area of circle with radius {radius} is {area}")

 

18. Display perimeter of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

perimeter = 2 * (length + breadth)

print(f"Perimeter of rectangle = {perimeter}")

 

19. Display perimeter of square.

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

perimeter = 4 * side

print(f"Perimeter of square with side {side} is {perimeter}")

 

20. Display circumference of circle.

radius = float(input("Enter the radius of the circle: "))

circumference = 2 * (22 / 7) * radius

print(f"Circumference of circle with radius {radius} is {circumference}")

 

21. Display area and perimeter of rectangle.

length = int(input("Enter the length of rectangle: "))

breadth = int(input("Enter the breadth of rectangle: "))

area = length * breadth

perimeter = 2 * (length + breadth)

print(f"Area of rectangle is {area}")

print(f"Perimeter of rectangle is {perimeter}")

 

22. Display area and perimeter of square.

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

area = side * side       

perimeter = 4 * side

print(f"Area of square with side {side} is {area}")

print(f"Perimeter of square with side {side} is {perimeter}")

 

23. Display area and circumference of circle.

radius = float(input("Enter the radius of the circle: "))

area = 22 / 7 * (radius ** 2)

circumference = 2 * 22 / 7 * radius

print(f"Area of circle with radius {radius} is {area}")

print(f"Circumference of circle with radius {radius} is {circumference}")

 

24. Display area of 4 walls.

length = float(input("Enter the length of the room: "))

breadth = float(input("Enter the breadth of the room: "))

height = float(input("Enter the height of the room: "))

area_walls = 2 * (length + breadth) * height

print(f"Area of 4 walls of room is {area_walls}")

 

25. Display area of triangle.

base = float(input("Enter the base of the triangle: "))

height = float(input("Enter the height of the triangle: "))

area = 0.5 * base * height

print(f"Area of triangle with base {base} and height {height} is {area}")

 

26. Display area of parallelogram.

base = float(input("Enter the base of the parallelogram: "))

height = float(input("Enter the height of the parallelogram: "))

area = base * height

print(f"Area of parallelogram is {area}")

 

27. Display area of triangle when three sides are given.

a = float(input("Enter first side of the triangle: "))

b = float(input("Enter second side of the triangle: "))

c = float(input("Enter third side of the triangle: "))

s = (a + b + c) / 2  

area = (s * (s - a) * (s - b) * (s - c)) ** 0.5  

print(f"Area of triangle with sides {a}, {b}, {c} is {area}")

No comments:

Post a Comment