{"id":18960,"date":"2021-08-29T15:12:53","date_gmt":"2021-08-29T09:42:53","guid":{"rendered":"https:\/\/python-programs.com\/?p=18960"},"modified":"2021-11-22T18:37:10","modified_gmt":"2021-11-22T13:07:10","slug":"python-program-to-calculate-the-surface-area-and-volume-of-a-hemisphere","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-calculate-the-surface-area-and-volume-of-a-hemisphere\/","title":{"rendered":"Python Program to Calculate the Surface Area and Volume of a Hemisphere"},"content":{"rendered":"
In the previous article, we have discussed Python Program to Compute x^n\/n!<\/a> Python’s math module is a built-in module. By importing this module, we can perform mathematical computations.<\/p>\n Numerous mathematical operations like ceil( ),floor( ),factorial( ),mod( ),value of pi ,…..etc .can be computed with the help of math module.<\/p>\n Hemisphere:<\/strong><\/p>\n The word hemisphere can be broken down into hemi and sphere, where hemi means half and sphere is a 3D geometric shape used in mathematics.<\/p>\n As a result, a hemisphere is a three-dimensional geometric shape that is half of a sphere, with one side flat and the other as a circular bowl.<\/p>\n Formula to calculate the surface area of a Hemisphere<\/strong>:<\/b><\/p>\n surface area = 3\ud835\uded1r\u00b2<\/strong><\/p>\n In which, r<\/strong> is the radius of the hemisphere.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to Calculate the surface area and volume of a hemisphere with the given hemisphere’s\u00a0 radius :<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n In the previous article, we have discussed Python Program to Compute x^n\/n! Math Module : Python’s math module is a built-in module. By importing this module, we can perform mathematical computations. Numerous mathematical operations like ceil( ),floor( ),factorial( ),mod( ),value of pi ,…..etc .can be computed with the help of math module. Hemisphere: The word …<\/p>\n
\nMath Module :<\/strong><\/p>\nGiven Hemisphere's Radius = 9<\/pre>\n
The Surface Area of the given Hemisphere with radius { 9 } = 763.02\r\nThe Volume of the given Hemisphere with radius { 9 } = 1526.04<\/pre>\n
Given Hemisphere's Radius = 12.5<\/pre>\n
The Surface Area of the given Hemisphere with radius { 12.5 } = 1471.875\r\nThe Volume of the given Hemisphere with radius { 12.5 } = 4088.5416666666665<\/pre>\n
Program to Calculate the Surface Area and Volume of a Hemisphere in Python<\/h2>\n
\n
Method #1: Using Mathematical Formula (Static Input)<\/h3>\n
\n
# Import the math module using the import keyword.\r\nimport math\r\n# Give the hemisphere's radius as static input and store it in a variable.\r\ngvn_radus = 9\r\n# Take a variable and initialize it with the value of pi as 3.14 .\r\nvalof_pi = 3.14\r\n# Calculate the surface area of the given hemisphere using the above given mathematical\r\n# formula and math.pow() function.\r\n# Store it in another variable.\r\nhemi_surfceara = 3*valof_pi*math.pow(gvn_radus, 2)\r\n# Calculate the volume of the given hemisphere using the above given mathematical formula\r\n# and math.pow() function.\r\n# Store it in another variable.\r\nhemi_volum = (2.0\/3.0)*valof_pi*math.pow(gvn_radus, 3)\r\n# Print the hemisphere's surface area with the given radius of the hemisphere.\r\nprint(\"The Surface Area of the given Hemisphere with radius {\",\r\n gvn_radus, \" } = \", hemi_surfceara)\r\n# Print the hemisphere's perimeter with the given radius of the hemisphere.\r\nprint(\"The Volume of the given Hemisphere with radius {\",\r\n gvn_radus, \"} = \", hemi_volum)\r\n<\/pre>\n
The Surface Area of the given Hemisphere with radius { 9 } = 763.02\r\nThe Volume of the given Hemisphere with radius { 9 } = 1526.04<\/pre>\n
Method #2: Using Mathematical Formula (User Input)<\/h3>\n
\n
# Import the math module using the import keyword.\r\nimport math\r\n# Give the hemisphere's radius as user input using the float(input()) function and\r\n# store it in a variable.\r\ngvn_radus = float(input(\"Enter some random variable = \"))\r\n# Take a variable and initialize it with the value of pi as 3.14 .\r\nvalof_pi = 3.14\r\n# Calculate the surface area of the given hemisphere using the above given mathematical\r\n# formula and math.pow() function.\r\n# Store it in another variable.\r\nhemi_surfceara = 3*valof_pi*math.pow(gvn_radus, 2)\r\n# Calculate the volume of the given hemisphere using the above given mathematical formula\r\n# and math.pow() function.\r\n# Store it in another variable.\r\nhemi_volum = (2.0\/3.0)*valof_pi*math.pow(gvn_radus, 3)\r\n# Print the hemisphere's surface area with the given radius of the hemisphere.\r\nprint(\"The Surface Area of the given Hemisphere with radius {\",\r\n gvn_radus, \" } = \", hemi_surfceara)\r\n# Print the hemisphere's perimeter with the given radius of the hemisphere.\r\nprint(\"The Volume of the given Hemisphere with radius {\",\r\n gvn_radus, \"} = \", hemi_volum)\r\n<\/pre>\n
Enter some random variable = 12.5\r\nThe Surface Area of the given Hemisphere with radius { 12.5 } = 1471.875\r\nThe Volume of the given Hemisphere with radius { 12.5 } = 4088.5416666666665<\/pre>\n<\/div>\n
\n