Answer:
Program :
def var_input():
#input function which takes the radius as input.
radius= float(input("Enter the radius of the sphere"))
#statemet to take the inputs.
volume(radius) /#call the volume function.
def volume(radius): #definition of volume function.
print("The volume of the sphere is :"+"{:.2f}".format((4/3)*(22/7)*radius*radius*radius)) # print the volume of the sphere.
var_input() # calling the input function.
Output:
- If the user inputs 4, then he will gets "268.19" as the output.
- If the user inputs 5, then he will gets "523.81" as the output.
Explanation:
- The above code is in python language, in which the first line is used to call the function.
- Then the first line of the input function is used to render the message to the user and take the inputs from the user and store it into the radius variable.
- Then the second line calls the volume function by passing the radius value.
- Then the volume function calculates the volume and prints it.