(In Python 3) For this assignment, you would use a menu driven option to calculate the volume and surface area of cylinder as well as a cone using functions. Use the cylinder_volume(r, h) and the cylinder_surface_area(r, h) from Week 9 lab and expand your code to also calculate the surface area and the volume of the cone using functions. Your tasks are as follows: Define a function called cone_volume(r, h) that that takes two arguments from user: radius r and height h, and prints the volume rounded to two decimal places (no need to return the value). Define a function called cone_surface_area(r, l) that takes two arguments from user: radius r and slant height l, and prints the surface area of the cone rounded to two decimal places (no need to return the value). Display a menu to ask the user to input their choice. Based on the choice selected, ask the user for corresponding input for r,h, and/or l. Inputs need to be float. Hint: you can input the values inside the if statements when comparing the options with the user's choice for the menu. Use default parameter values for all the functions of your choice. Formulae: Volume of a cone: 13πr2h13πr2h Surface Area of a cone: πrl+πr2πrl+πr2 Volume of a cylinder: πr2hπr2h Surface Area of a cylinder 2πr2+2πrh2πr2+2πrh A sample run is show below: **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 1 Enter radius: 22.5 Enter height: 10.5 Volume of the cone for radius 22.5 and height 10.5 is: 5566.51 **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 7 Wrong choice entered. **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 5 Goodbye!
(In Python 3)
For this assignment, you would use a menu driven option to calculate the volume and surface area of cylinder as well as a cone using functions.
Use the cylinder_volume(r, h) and the cylinder_surface_area(r, h) from Week 9 lab and expand your code to also calculate the surface area and the volume of the cone using functions.
Your tasks are as follows:
- Define a function called cone_volume(r, h) that that takes two arguments from user: radius r and height h, and prints the volume rounded to two decimal places (no need to return the value).
- Define a function called cone_surface_area(r, l) that takes two arguments from user: radius r and slant height l, and prints the surface area of the cone rounded to two decimal places (no need to return the value).
- Display a menu to ask the user to input their choice. Based on the choice selected, ask the user for corresponding input for r,h, and/or l. Inputs need to be float. Hint: you can input the values inside the if statements when comparing the options with the user's choice for the menu.
- Use default parameter values for all the functions of your choice.
Formulae:
Volume of a cone: 13πr2h13πr2h
Surface Area of a cone: πrl+πr2πrl+πr2
Volume of a cylinder: πr2hπr2h
Surface Area of a cylinder 2πr2+2πrh2πr2+2πrh
A sample run is show below:
**** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 1 Enter radius: 22.5 Enter height: 10.5 Volume of the cone for radius 22.5 and height 10.5 is: 5566.51 **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 7 Wrong choice entered. **** Menu **** 1. Volume of a Cone 2. Surface of a Cone 3. Volume of a Cylinder 4. Surface of a Cylinder 5. Quit Enter your choice (1-5): 5 Goodbye!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images