190k views
1 vote
The surface area of a sphere can be computed by knowing only the radius of the sphere using the following relation: A = 4 π r 2 Unlike in previous questions where we wanted you to complete a function we had started, here we want you to write a Python function from scratch called surf_area_sphere that takes a single parameter, the radius of a sphere as a floating point number, and returns the surface area of that sphere. You can name your parameter whatever you want.

1 Answer

2 votes

Answer:

// program in Python.

#library

import math

#function to find surface area of sphere

def surf_area_sphere(rad):

# calculate area and return it

return 4*math.pi*rad**2

#read the radius of sphere

rad=float(input("Enter the radius of sphere:"))

#call the function to find the Surface area

s_area=surf_area_sphere(rad)

#print the Surface area

print("Surface area is:",s_area)

Step-by-step explanation:

Read the radius of sphere from user and assign it to variable "rad".Then call the function surf_area_sphere() with parameter "rad".This function will calculate the surface area as "4*pi*r*r" and return it value.Then print the surface area of sphere.

Output:

Enter the radius of sphere:4

Surface area is: 201.06192982974676

User Andreas Lochbihler
by
4.4k points