Random float
Randomness has many uses in science, art, statistics, cryptography, gaming, gambling, and other fields. You're going to use randomness to simulate a game.
All the functionality you need is contained in the random package, a sub-package of numpy. In this exercise, you'll be using two functions from this package:
- seed(): sets the random seed, so that your results are the reproducible between simulations. As an argument, it takes an integer of your choosing. If you call the function, no output will be generated.
- rand(): if you don't specify any arguments, it generates a random float between zero and one.
This exercise is part of the course
Intermediate Python for Data Science
Exercise instructions
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import numpy as np
# Set the seed
# Generate and print random float