Python Program to Calculate Volume and Surface Area of Hemisphere

In the previous article, we have discussed Python Program to Calculate Volume of Dodecahedron
Given the radius value of the hemisphere, the task is to find the Volume and Surface Area of the given Hemisphere in Python.

Hemisphere:

It is the precise half of a sphere in geometry. Many real-life examples of hemispheres may be found, such as our planet Earth, which is divided into two hemispheres, the southern and northern hemispheres.

Examples:

Example1:

Input:

Given Radius of Hemisphere = 7

Output:

The Surface Area of the Hemisphere with radius { 7 } is = 307.8760800517997
The Volume of the Hemisphere with radius { 7 } is = 718.377520120866

Example2:

Input:

Given Radius of Hemisphere = 8

Output:

The Surface Area of the Hemisphere with radius { 8 } is = 402.1238596594935
The Volume of the Hemisphere with radius { 8 } is = 1072.330292425316

Program to Calculate Volume and Surface Area of Hemisphere

Below are the ways to Calculate the Volume and Surface Area of the Hemisphere in Python.

surface area of the Hemisphere = 2 pi r^2
volume of the Hemisphere = frac{2 pi r^2}{3}

Method #1: Using Mathematical Formula (Static Input)

Approach:

  • Import the math module using the math keyword.
  • Give the radius of the hemisphere as static input and store it in a variable.
  • We can get the pi value using the pi() function.
  • We can Calculate the power using the pow() function
  • Calculate the surface area of the hemisphere with the given radius using the above given mathematical formula
  • (2 pi r^2)and functions and store the result in some variable say hemiArea.
  • Calculate the volume of the hemisphere with the given radius using the above given mathematical formula
  • ( frac{2 pi r^2}{3})and functions and store the result in some variable say hemiVolume.
  • Print the hemiArea to get the Surface Area of the given hemisphere.
  • Print the hemiVolume to get the Volume of the given hemisphere.
  • The Exit of the Program.

Below is the implementation:

# Import the math module using the math keyword.
import math
# Give the radius of the hemisphere as static input and store it in a variable.
radiusHemi = 7
# We can get the pi value using the pi() function.
# We can Calculate the power using the pow() function
# Calculate the surface area of the hemisphere with the given radius
# using the above given mathematical formula
# and functions and store the result in some variable say hemiArea.
hemiArea = 2 * math.pi * math.pow(radiusHemi, 2)
# Calculate the volume of the hemisphere with the given radius
# using the above given mathematical formula
# and functions and store the result in some variable say hemiVolume.
hemiVolume = 2 * math.pi * math.pow(radiusHemi, 3) / 3
# Print the hemiArea to get the Surface Area of the given hemisphere.
print(
    'The Surface Area of the Hemisphere with radius {', radiusHemi, '} is =', hemiArea)
# Print the hemiVolume to get the Volume of the given hemisphere.
print(
    'The Volume of the Hemisphere with radius {', radiusHemi, '} is =', hemiVolume)

Output:

The Surface Area of the Hemisphere with radius { 7 } is = 307.8760800517997
The Volume of the Hemisphere with radius { 7 } is = 718.377520120866

Method #2: Using Mathematical Formula (User Input)

Approach:

  • Import the math module using the math keyword.
  • Give the radius of the hemisphere as user input using the int(input()) function and store it in a variable.
  • We can get the pi value using the pi() function.
  • We can Calculate the power using the pow() function
  • Calculate the surface area of the hemisphere with the given radius using the above given mathematical formula
  • (2 pi r^2)and functions and store the result in some variable say hemiArea.
  • Calculate the volume of the hemisphere with the given radius using the above given mathematical formula
  • ( frac{2 pi r^2}{3})and functions and store the result in some variable say hemiVolume.
  • Print the hemiArea to get the Surface Area of the given hemisphere.
  • Print the hemiVolume to get the Volume of the given hemisphere.
  • The Exit of the Program.

Below is the implementation:

# Import the math module using the math keyword.
import math
# Give the radius of the hemisphere as user input using the int(input()) function
# and store it in a variable.
radiusHemi = int(input('Enter some random radius of the Hemisphere = '))
# We can get the pi value using the pi() function.
# We can Calculate the power using the pow() function
# Calculate the surface area of the hemisphere with the given radius
# using the above given mathematical formula
# and functions and store the result in some variable say hemiArea.
hemiArea = 2 * math.pi * math.pow(radiusHemi, 2)
# Calculate the volume of the hemisphere with the given radius
# using the above given mathematical formula
# and functions and store the result in some variable say hemiVolume.
hemiVolume = 2 * math.pi * math.pow(radiusHemi, 3) / 3
# Print the hemiArea to get the Surface Area of the given hemisphere.
print(
    'The Surface Area of the Hemisphere with radius {', radiusHemi, '} is =', hemiArea)
# Print the hemiVolume to get the Volume of the given hemisphere.
print(
    'The Volume of the Hemisphere with radius {', radiusHemi, '} is =', hemiVolume)

Output:

Enter some random radius of the Hemisphere = 8
The Surface Area of the Hemisphere with radius { 8 } is = 402.1238596594935
The Volume of the Hemisphere with radius { 8 } is = 1072.330292425316

Grab the opportunity and utilize the Python Program Code Examples over here to prepare basic and advanced topics too with ease and clear all your doubts.