languages | tags |
---|---|
python |
functions, random, looping |
Open the dice_roll.py file and run it. It should roll two dice five times, printing the rolls of each pair. Look at the code and get familiar with it. You will modify this program in three ways:
-
Rather than rolling the dice a fixed number of times (like the original version does), we now want to keep rolling the dice until we hit double sixes. The program should stop as soon as it rolls the first double sixes.
-
You should make the program print something when it rolls either two ones or two sixes.
-
Rather than telling the user how many times we will roll the dice, tell the user how many dice rolls it took to hit double sixes.
The output of your program should look something like this:
$ python dice_roll.py
Rolls: 2 1
Rolls: 1 4
Rolls: 3 1
Rolls: 6 1
Rolls: 1 3
Rolls: 1 3
Rolls: 1 1
Got snake eyes!
Rolls: 4 6
Rolls: 4 1
Rolls: 3 1
Rolls: 4 2
Rolls: 4 1
Rolls: 4 4
Rolls: 6 4
Rolls: 3 6
Rolls: 3 1
Rolls: 5 4
Rolls: 2 6
Rolls: 6 6
Got double sixes!
Rolled the dice 19 times