Answer to Question #320895 in Python for leigh

Question #320895

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


1
Expert's answer
2022-04-02T19:08:31-0400

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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS