Python200

Generate random numbers in Python without using Random module

Generating random numbers in Python without using the built-in random the module can be challenging, as the process of generating truly random numbers requires specialized hardware or algorithms. However, one approach could be to use some other source of randomnesses, such as the current time or the user’s input, to simulate randomness.

Here’s an example program that generates a “random” number based on the user’s input:

The above Python program prompts the user to enter a number, which is used as a “seed” for the pseudo-random number generator. The program then generates a “random” number by multiplying the seed by a large prime number and taking the remainder when divided by a large integer (in this case, 1,000,000). While this method is not truly random, it can produce results that are unpredictable and appear to be random.

Note: This approach should not be used for security-critical applications, as it is relatively easy to predict the “random” numbers generated using this method.

Hope this program is helpful for you. Keep reading!

Related Posts

Leave a Reply