Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
It looks like youre working on a Python program using CodeSkulptor and you need assistance with the ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started