Saturday, 28 August 2021

Python Program : 3 : Compute volume of following 3D shapes: cube, cylinder, cone and sphere.

PROGRAM :-
import math
PI = math.pi
print("--------------------------------")
print("  ....Enter your choice....")
print("whose volume u want to calculate")
print("--------------------------------")
print("\t1. CUBE")
print("\t2. CYLINDER")
print("\t3. CONE")
print("\t4. SPHERE")
print("--------------------------------")
n = int(input("Enter your choice : "))
if n == 1:
    s1 = int(input("Enter Side : "))
    V1 = s1*s1*s1
    print("Volume of Cube : ",round(V1,2))
elif n == 2:
    r2 = int(input("Enter Radius : "))
    h2 = int(input("Enter Height : "))
    V2 = PI*r2*r2*h2
    print("Volume of Cylinder : ",round(V2,2))
elif n == 3:
    r3 = int(input("Enter Radius : "))
    h3 = int(input("Enter Height : "))
    V3 = PI*r3*r3*h3/3
    print("Volume of Cone : ",round(V3,2))
elif n == 4:
    r4 = int(input("Enter Radius : "))
    V4 = 4*PI*r4*r4*r4/3
    print("Volume of Sphere : ",round(V4,2))
else:
    print("...Please enter correct choice...")   
 
VIDEO LINK : -


No comments:

Post a Comment

Note: only a member of this blog may post a comment.