Theory of probability is a fascinating topic by itself and get becomes even more fascinating if you apply it to games.
To apply it to games with python, you need to import python's
random module (witch is shipped with python).
To simulate the throw of a six-sided dice, write:
import random result = random.randint(1,6) # lower bond, upper bond print result
You can find out all functions of the
random module by typing at the python prompt:
>>>import random >>>help("random")
Some functions i tend to use frequently are:
random.randint(a, b)creates a random integer between (including) a and b
radnom.random()creates a float between 0 and 1
random.choice(list)randomly choose one element of a list