0

1 or i?

Why Not "import random for i in range(5): value = random.randint(i, 6) print(value)" Instead of "import random for i in range(5): value = random.randint(1, 6) print(value)" ?

6th Feb 2019, 1:23 PM
Steffi Klemm
Steffi Klemm - avatar
1 ответ
+ 3
The two codes will output different values. The first prints 5 random values within a different range each time: 0 to 6, 1 to 6, 2 to 6, 3 to 6, and 4 to 6. The second prints 5 random values within the same range: 1 to 6. Therefore, the first would tend to have higher numbers than the second.
7th Feb 2019, 2:25 AM
John Wells
John Wells - avatar