Dice shots_2¶
To conduct a statistic survey, several shots of two dice are performed. The two dice are shot simultaneously and the results are recorded in a list. Each element in the list is a tuple with two integers from 1 to 6: the values shown on the upper face of both dice.
Write a function dice2() that takes the list of results of
the shots and returns the percentage of shots in which both dice show
the same result. Save the function in a module named dice.py. Examples:
>>> round(dice2([(1, 2), (1, 4,), (6, 6), (6, 6), (2, 3), (3, 3), (4, 4), (4, 5), (2, 2)]), 2) 55.56 >>> round(dice2([(1, 1), (2, 2), (6, 6)]), 2) 100.0 >>> round(dice2([(1, 2), (3, 4), (5, 5), (1, 2), (1, 4), (6, 5), (4, 1)]), 2) 14.29Note
More tests are provided in the
dice.txtfile.
Solution
A solution of these functions is provided in the
dice.py file.