Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago