मराठी

The volume of a sphere with radius r is π43πr3. Write a Python program to find the volume of spheres with radii 7cm, 12cm, and 16cm, respectively. - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

The volume of a sphere with radius r is `4/3πr^3`. Write a Python program to find the volume of spheres with radii 7cm, 12cm, and 16cm, respectively.

थोडक्यात उत्तर
Advertisements

उत्तर

Program:
#defining three different radius using variables r1, r2, r3
r1 = 7
r2 = 12
r3 = 16
#calculating the volume using the formula
volume1 = (4/3*22/7*r1**3)
volume2 = (4/3*22/7*r2**3)
volume3 = (4/3*22/7*r3**3)

#printing the volume after using the round function to two decimal places for better readability

print("When the radius is",r1,"cm, the volume of the sphere will be", round(volume1,2),"cc")
print("When the radius is",r2,"cm, the volume of the sphere will be", round(volume2,2),"cc")
print("When the radius is",r3,"cm, the volume of the sphere will be", round(volume3,2),"cc")


OUTPUT:
When the radius is 7 cm, the volume of the sphere will be 1437.33 cc
When the radius is 12 cm, the volume of the sphere will be 7241.14 cc
When the radius is 16 cm, the volume of the sphere will be 17164.19 cc
shaalaa.com
Operators - Arithmetic Operators (-,+,*,/,%)
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 5: Getting Started with Python - Exercise [पृष्ठ ११८]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
पाठ 5 Getting Started with Python
Exercise | Q 18. | पृष्ठ ११८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×