Daniel Nogueira
Posted on November 5, 2022
A practical way of doing that's using the random
library. Let's import it:
import random
Among the random
methods, there is the randint
method, that returns an integer value within a specified range.
random.randint(0,10)
Just use a variable to store the value the function will return and that's it, we can display the value the computer thought.
x = random.randint(0,10)
print(x)
💖 💪 🙅 🚩
Daniel Nogueira
Posted on November 5, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
python Mastering Python’s __name__ and __main__: Understanding Script Execution and Module Imports
November 1, 2024
raspberrypi Controlling an LED with a Snap Using the KY-037 Sound Sensor and Raspberry Pi
October 6, 2024