Here is a simple Python program that can generate a random number:
import random # Generate a random integer between 1 and 100 random_number = random.randint(1, 100) print(random_number)
This program uses the
random.randint() function to generate a random integer between 1 and 100, inclusive. This function is part of the
random module, so you will need to import it at the beginning of your program.
You can customize the range of the random number by changing the arguments passed to the
random.randint() function. For example, you could use
random.randint(10, 20) to generate a random integer between 10 and 20, inclusive.
Keep in mind that this program will generate a different random number each time it is run. This is because the
random module uses a “pseudorandom” number generator, which produces a sequence of numbers that are statistically random, but are generated using a deterministic algorithm. This means that if you know the starting point (the “seed” value) of the generator, you can predict all of the numbers that it will produce. However, if you don’t know the seed value, the numbers will appear random.
Thanks for reading. Happy coding!