Square:
Side length
Print the area, perimeter and volume of a square
Rectangle:
Width; length; height
Print the area, perimeter and volume of a rectangle
Circle :
radius
Print the area, perimeter and volume of a circle
triangle:
Base height
Print the area, of a triangle
Use the following set of codes:
# calculate area, perimeter and volume of a square
length = int(input("Enter length of a square: "))
area = length ** 2
print("Area is:", area)
perimeter = length * 4
print("Perimeter is:", perimeter)
volume = length ** 3
print("Volume is:", volume)
# calculate area, perimeter and volume of a rectangle
length = int(input("Enter length of a rectangle: "))
width = int(input("Enter width of a rectangle: "))
height = int(input("Enter height of a rectangle: "))
area = length * width
print("Area is:", area)
perimeter = 2 * (length + width)
print("Perimeter is:", perimeter)
volume = length * width * height
print("Volume is:", volume)
# calculate area, perimeter and volume of a circle
radius = int(input("Enter radius of a circle: "))
height = int(input("Enter height of a circle: "))
area = (22/7) * (radius **2)
print("Area is:", area)
perimeter = 2 * (22/7) * radius
print("Perimeter is:", perimeter)
volume = (22/7) * (radius ** 2) * (height)
print("Volume is:", volume)
# calculate area of a triangle
base = int(input("Enter base length of a triangle: "))
height = int(input("Enter height of the triangle: "))
area = (1/2) * base * height
print("Area is:", area)
Comments
Leave a comment