Skip to content

Tag: random

Generating dictionary does not always work

I am trying to generate a dictionary automatically with a for loop (i < numero_usuarios), the keys are taken from a list with names, and the values are randomly generated with a random.randint(1, 10), the problem is that it does not always generate the amount I want. For instance, I want to create 10 users…

Assigning keys and storing in a dictionary Python

For an event of rolling a six-sided die. I need to randomly simulate the event 1000 times and plot a histogram of results for each number on the dice. I want to assign the results for each number to a key of the same value (1 for number of 1s{1:164…}). I need help assigning keys and storing everyting in…

Random numbers, small decimals

I’m working with random numbers in python, the problem is the following; I have a variable, we can call it “x”, I want it to take values between [10^-6,10^-1], then I have the following line But it is only generating numbers like It never generates numbers like How can I generate the second …

sending random messages with smtplib python

I want to send random messages using smtplib in python, I wrote this code: I’ve received the messages but with the same string, I also tried to make a list of random strings and then make the message variable chose randomly from there using random.choice() but it didn’t work either. What could the…

Seedable CSPRNG for python?

With the random module, you are able to seed it to get the same values every time. Is there a CSPRNG that can do this? For example, according to this question How can I create a random number that is cryptographically secure in python?, random.SystemRandom is secure. But seeding it doesn’t return the sa…