Generate a random number
Python includes a library called random
that helps you generate random numbers. You can use this in your program by writing import random
at the top of your program and using the randint
function to generate a number between a range.
This would generate a random number between 1 and 10.
random.randint(1,10)
Try running the below code a few times to see what you get!
You can also play around by changing the range of random numbers. It’s fun, give it a try!