Skip to content
Advertisement

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(usuarios), it sometimes creates 7, 8

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 a

How do I randomly select multiple images from folders and then layer them as a single image in Python?

I’m trying to use python to create a composite .png of randomly selected and layered png’s all with transparent backgrounds, so all layers are visible in the finished piece. For example using different coloured circles of decreasing size: a folder of the largest circles called ‘layer1’ contains 3 different coloured circles of the same size and position on transparent backgrounds,

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 type of random numbers? Generating random numbers

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 problem be? Answer Your mistake: generating one

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 same thing. Does such a CSPRNG exist?

Advertisement