Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

vTo practice using modules and simple conditionals For this question, you ll write a program that checks whether a randomly generated integer is a perfect

vTo practice using modules and simple conditionals
For this question, youll write a program that checks whether a randomly generated integer is a perfect
cube. A perfect cube is an integer for which the cube root is also an integer.
First, your program should import both the random and math modules. Make sure to use the import syntax
as shown in the course readings.
Then, your program should generate a random number between 1 and 10000(inclusive).
Finally, your program should display that number to the console. If the number is a perfect cube, an addi-
tional message should be displayed to say so. Use a conditional statement along with any functions from
the math module that you think you need to do this.
Sample Run
Here is a possible sample run (output value of a variable is shown in blue text):
Your random number is : 5062
Here is another one.
Your random number is : 125
Amazing !125 is a perfect cub

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions