- """ Program to calculate area and perimeter of square """
- side= float(input("Enter a side length of the square: "))
- area = side ** 2
- perimeter = 4 * side
- print("Area of the square:",area)
- print("Perimeter of the square:", perimeter)
- OUTPUT :
- Enter a side length of the square: 6
- Area of the square: 36.0
- Perimeter of the square: 24.0
- """ Program to calculate area and perimeter of rectangle """
- length= float(input("Enter length of the rectangle: "))
- width= float(input("Enter width of the rectangle: "))
- area = length * width
- perimeter = 2 * (length + width)
- print("Area of the rectangle:",area)
- print("Perimeter of the rectangle:",perimeter)
- OUTPUT ;
- Enter length of the rectangle: 12
- Enter width of the rectangle: 14
- Area of the rectangle: 168.0
- Perimeter of the rectangle: 52.0
- """" Program to calculate area and perimeter of circle """
- import math
- radius = float(input("Enter radius of the circle: "))
- area = math.pi * radius ** 2
- perimeter = 2 * math.pi * radius
- print("Area of the circle:",area)
- print("Perimeter of the circle:", perimeter)
- OUTPUT :
- Enter radius of the circle: 5
- Area of the circle: 78.53981633974483
- Perimeter of the circle: 31.41592653589793
- """ Program to calculate area of triangle """
- base=float(input("Enter base of triangle: "))
- height=float(input("Enter height of triangle: "))
- area=(base*height)/2
- print("Area is =",area)
- OUTPUT :
- Enter base of triangle: 5
- Enter height of triangle: 4
- Area is = 10.0
- """ Program to calculate area of triangle by Heron's formula """
- import math
- a = float(input("Enter the first side of the triangle: "))
- b = float(input("Enter the second side of the triangle: "))
- c = float(input("Enter the third side of the triangle: "))
- s = (a + b + c) / 2
- area = math.sqrt(s * (s-a) * (s-b) * (s-c))
- print("Area of the triangle: ", area)
- OUTPUT :
- Enter the first side of the triangle: 5
- Enter the second side of the triangle: 6
- Enter the third side of the triangle: 8
- Area of the triangle: 14.981238266578634