Question: please use python, thanks! Cylinder Write a program that calculates the volume of a cylinder. Your program will get the radius of the cylinder's base
please use python, thanks!
Cylinder
Write a program that calculates the volume of a cylinder.
Your program will get the radius of the cylinder's base r and the height of the cylinder h as command line arguments. The radius will be given first.
Your program may encounter these unusual situations:
Program receives less than two arguments: print the message Not enough arguments.
Program receives more than two arguments: print the message Too many arguments.
Radius is negative: print the message Radius cannot be negative.
Height is negative (but radius is non-negative): print the message Height cannot be negative.
For all situations listed above, the program should terminate immediately after the message has been printed.
The value of pi should be set as a constant with the value 3.141592.
The volume of the cylinder should be printed to 2 decimal places, and can be calculated using the formula:
V=r2h
Example 1:
$ python cylinder.py 4 10 The volume of the cylinder is 502.65.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
