jeudi 6 avril 2017

Function in a for loop

this is my code:

import random

a = 10000
b = random.random()
c = 2

def random1(a,b,c):
    z = a * b * c
    print(z)

def random2():
    for i in range(10):
        random1(a,b,c)

random2()

I have a problem with my output, because function random2() gives me ten exactly the same number, for example:

10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188
10652.014111193188

Where is the mistake? Or I can't use function that gives me random numbers in a for loop :/. Everything if fine, when I'm looping formula instead of function, the problem shows only when function is in for loop.




Aucun commentaire:

Enregistrer un commentaire