mardi 4 septembre 2018

How can I generate random numbers and store them in a random amount of re-callable variables?

So, I am trying to write a program that outputs (prints) a random number between (x = 1-1000) a random amount of times between (n = 1-10) and stores those numbers in the same random number (n) of re-callable variables. That way I can output(print) the smallest number (min) of the (x) random numbers. Here's my code so far:

from random import randint

for x in range (10):
    x = randint (1,1000)

for n in range (10):
    n = randint (1,10)

while n > 0:
    print(x)
    num(n) = x    
    for x in range (10):
        x = randint (1,1000)

    n = n - 1

def num_low():
    min[num(n)]

print('lowest number is', num_low())

As you can see, I am trying to put them into a variable by the name num(n) where (n) is the randomly generated (1-10) number so that you end up with num 1, num 2, num 3,.....num (n) etc. That way you have all the required variables and as the while loop continues it should change the name of the variable to a different name automatically. Then once they are all stored I can recall them for a min check and output the minimum variable.




Aucun commentaire:

Enregistrer un commentaire