In Python A soup company is interested in finding out how much of their soup will go into various sized cans. The user will input the diameter of the can end, and the height of the can. The volume of a cylinder is the well known formula: volume = area of the ends * height of cylinder. The twist is that a can of soup can not be completely filled to the top; only 95% of the volume can be filled with soup; the remaining 5% must remain empty to allow for expansion. NOTE: when computing the area, use pi to at least 5 significant digits (eg, 3.14159) or use the constant math.pi. You should define a function named soup_volume which takes two parameters, the diameter of the can in cm, and the height of the can in cm, in that order. The function should return a float value, which is the volume of soup that the can is able to hold. The function should not round the value, but when printing the value in the main program, format it to show only 2 decimal places. Example run of the program: Enter the diameter of the can in cm: 5 Enter the height of the can in cm: 10 The can holds 186.53 cubic cm of soup. # Define your function here if __name__ == '__main__': d = float(input("Enter the diameter of the can in cm:\n")) # continue the rest of the program here
In Python
A soup company is interested in finding out how much of their soup will go into various sized cans. The user will input the diameter of the can end, and the height of the can. The volume of a cylinder is the well known formula: volume = area of the ends * height of cylinder. The twist is that a can of soup can not be completely filled to the top; only 95% of the volume can be filled with soup; the remaining 5% must remain empty to allow for expansion. NOTE: when computing the area, use pi to at least 5 significant digits (eg, 3.14159) or use the constant math.pi.
You should define a function named soup_volume which takes two parameters, the diameter of the can in cm, and the height of the can in cm, in that order. The function should return a float value, which is the volume of soup that the can is able to hold. The function should not round the value, but when printing the value in the main program, format it to show only 2 decimal places.
Example run of the program:
Enter the diameter of the can in cm:
5
Enter the height of the can in cm:
10
The can holds 186.53 cubic cm of soup.
# Define your function here
if __name__ == '__main__':
d = float(input("Enter the diameter of the can in cm:\n"))
# continue the rest of the program here
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images