Nauč se Python > Materiály > Snake Workshop for PyLadies > Introduction to Python > Randomness

Randomness – Řešení [0]

Numbers from 0 to 5 - not including 6. Programmers count from zero, and when you count six numbers from zero, you only get to five.

When you want to 'roll the dice' - select numbers from 1 to 6 - you can write:

>>> from random import randrange
>>> randrange(6) + 1
4

Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.