Build a Python Dice Game as a Coding Club Group Project
Your club has a student who has never written a loop, another who already knows classes, and a 90 minute session to keep both of them busy.

Your club has a student who has never written a loop, another who already knows classes, and a 90 minute session to keep both of them busy. Most group projects fail that test because the easy jobs run out in 20 minutes and the hard ones need knowledge half the room does not have. A Python dice game built as a team solves this, because every piece of it can be pitched at a different level.
I have run this project with groups of four to eight learners aged 12 to 60, and it consistently finishes in two or three sessions. The game is called Pig, a classic dice game that needs only one die and a target score.
How the Python dice game works
Pig has simple rules, which is exactly why it suits a mixed group. Players take turns rolling a single six sided die. On each roll you add the number to your turn total. You may keep rolling as long as you like, but if you roll a 1, your turn total is wiped and play passes to the next person. If you choose to stop, your turn total is added to your permanent score. The first player to reach 100 wins.
That gives you random numbers, loops, conditionals, functions, input handling and a little strategy, all in a program that rarely grows past 120 lines. Beginners get something they can play within the first session, and that early win matters more than any single concept.
Splitting the work by skill level
The trick is to cut the game into modules with clear inputs and outputs, then hand them out by confidence rather than by age. Here is the split I use:
| Module | Concepts | Good for |
|---|---|---|
| roll_die() | import, random.randint, return | First week beginners |
| ask_roll_or_hold() | input, while loop, string checks | Beginners with a few sessions behind them |
| play_turn() | loops, conditionals, calling functions | Intermediate learners |
| main game loop | lists, turn rotation, win check | Intermediate learners |
| computer player | strategy rules, simple decision logic | Confident coders |
| scoreboard and stats | dictionaries, formatting, files | Confident coders |
Agree on the function names and what each returns before anyone writes code. I put them on a whiteboard: roll_die returns an integer from 1 to 6, ask_roll_or_hold returns the string "r" or "h", and play_turn takes a player name and returns the points banked that turn. Writing this contract in plain words first is the same habit we teach in pseudocode before real code, and it stops two people building incompatible pieces.
Session plan for three meetings
Session one: a playable game
- Spend 15 minutes playing Pig with a real die so everyone understands the rules in their hands, not just on paper.
- Write the function contracts together on the board.
- Pairs build roll_die and ask_roll_or_hold. These take a beginner about 20 minutes with support.
- Stronger members write play_turn and the main loop, using stand in functions that return fixed values until the real ones arrive.
- In the last 15 minutes, paste everything into one file and play a two player game. It will be rough, and that is fine.
Session two: a computer opponent
This is where the confident coders earn their keep. The simplest strategy that plays well is "hold at 20": keep rolling until your turn total reaches 20, then stop. It is surprisingly strong against humans. A smarter version holds earlier when the opponent is close to 100. Meanwhile beginners can add input validation so that typing "R" or "roll" works instead of crashing.
Session three: polish and stats
Add a scoreboard, a replay option and a tally of how many times each player rolled a 1. Someone can write a simulation that plays 1,000 computer versus computer games and reports which strategy wins more often. That single task usually produces the best conversation of the whole project.
The usual advice about group roles is wrong here
Many club guides suggest giving each person a fixed role for the whole project, such as tester, designer or lead programmer. For a short project like this, I think that is a mistake.
Fixed roles lock beginners into the jobs that involve the least code. The "tester" plays the game a lot and writes very little Python. By session three they are bored and no more capable than when they started. Rotate instead. Each session, every learner should write at least one function they did not write before, even a tiny one. In my groups, the beginner who wrote roll_die in week one often writes the input validation in week two, and that progress is visible to them in a way a job title never is.
The one exception is version control. If your club uses Git, keep one confident person as the merge keeper for the whole project. Our guide to running a Git group project at your club explains why that role works better when it stays put.
Common bugs and how to coach through them
- The turn total never resets. The variable was created outside the loop. Ask the learner to point at the line where a new turn begins.
- random.randint(1, 6) never shows a 6. It does, they just need more rolls. Have them roll 60 times and count. This is a great small lesson about probability.
- The game never ends. The win check compares to 100 with == instead of >=, so a jump from 96 to 102 sails past.
- Input crashes on uppercase. Add .lower().strip() to the input before checking it.
One more appears in almost every group: the computer player rolls forever. This happens when the hold rule checks the permanent score instead of the turn total. Print both values on every roll and the mistake becomes obvious within a few turns.
Resist fixing these yourself.Ask questions until they spot it. That habit pays off long after this project.
When the game is finished, it makes a strong demo day piece, because visitors can play it in under two minutes. For more ideas that suit mixed groups, see our list of club projects that work with mixed skill levels.
Frequently asked questions
How do you make a dice game in Python?
Import the random module and use random.randint(1, 6) to simulate one roll. Wrap rolls in a while loop that asks the player whether to roll again or stop, and keep a running total. Add a second loop for turns and a check for the winning score.
Is a dice game a good first Python project?
Yes, because it uses random numbers, loops, conditionals and input in a program small enough to finish quickly. Learners see a working result in one session. It also grows naturally, so stronger learners can add an opponent or statistics without starting over.
How long does a Python dice game take a beginner group?
A playable version usually takes one 90 minute session with a group of four to eight. A computer opponent and a scoreboard add one or two more sessions. Groups with very new learners may need an extra session for input handling.
More in Club Projects
Club Projects
Build a Python Pair Rotation Tool for Club Nights
Our club pairs people up every week, and for two years I did it with a shuffled pack of index cards.
Club Projects
Build a Club Discord Bot as a Python Group Project
Our club ran a Discord bot as a group project for the first time two years ago, and the first version lived on one student's...
Club Projects
Build a Python Maze Solver as a Club Group Project
Most club projects split badly once the group has a real spread of skill.