In CodeSkulptor, click on the Docs button to see the CodeSkulptor documentation. Under the Standard Modules tab,
Fantastic news! We've Found the answer you've been seeking!
Question:
In CodeSkulptor, click on the Docs button to see the CodeSkulptor documentation.
Under the Standard Modules tab, read through the Math Module and the Random Module.
To use these modules in your program, begin your code with an import statement:
import math
import random
In the body of your program:
- Ask the user to give a radius value and store it as an integer (you will have to cast it to an integer!).
- Square the radius, then multiply the number by (using the constant pi stored in the math module) to give the area of a circle with that radius.
- Tell the user what the area is for that radius in a sentence. Include both the value of the radius and area. For example, if the user inputs the value 3, the sentence would look like "A circle with an radius of 3 has an area of 28.2743338823".
- Tell the user what two integers this is between by using functions in the math module that round down and round up. If you also cast them to integers, this will get rid of the .0 at the end.
- Tell the user what integer it's closest to by using the round() function. Note: this is built-in, not in the math module. Try using the seach bar in the docs to find it.
- Now use a function from the random module (read them all to see which one makes sense!) to get 3 random integers between 1 and 10 and store them as length, width and height.
- Calculate the volume of a box with these dimensions, then print a sentence to the user telling them.
- Give the user an approximate value to the nearest 10, and to the nearest 100, using the round function.
Related Book For
Introduction To Statistics And Data Analysis
ISBN: 9780495118732
3rd Edition
Authors: Roxy Peck, Chris Olsen, Jay L. Devore
Posted Date: