Tutorial for first year computer science students

Back to Tutorials

Dice Game 2 - While Loops

Learning Objectives

We are going to learn:

  1. How to use while loops.
  2. How to use break and continue.

Exercises

Download the Medialib ex8 files from the gallery and complete the program in ex8.py.

Modify the dice game created in exercise 5 to use a while loop so that the game continues until there is a tie:

  1. If the points of the 2 dices are different, the program will not end, but to start the next round after a mouse_left_click().
  2. Use clear() to clear the window before a new round.
  3. If the points of the 2 dices are the same, end the game, and print the total number of rounds
MediaLib Dice Game


Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.