Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🎲 Dice Rolling Game

A command-line Python application that simulates rolling one or more dice, tracks your session roll count, and handles invalid inputs gracefully.

Features

  • Roll any number of dice in a single turn
  • All dice show values between 1 and 6
  • Tracks total rolls across the session
  • Input validation — handles letters, negative numbers, and zero
  • Clean, modular code with unit tests

Demo

===================================
    Welcome to the Dice Rolling Game!
===================================
How many dice do you want to roll? 3
  Dice 1: 4
  Dice 2: 1
  Dice 3: 6
  Total rolls this session: 1

Roll again? (y/n): y
How many dice do you want to roll? abc
  Invalid input. Please enter a whole number.
How many dice do you want to roll? 2
  Dice 1: 3
  Dice 2: 5
  Total rolls this session: 2

Roll again? (y/n): n

Thanks for playing! Goodbye 🎲

Getting Started

Prerequisites

  • Python 3.10 or higher

Installation

git clone https://github.com/sanamuqqadus393-arch/Dice-Rolling-Game.git
cd Dice-Rolling-Game

Run the game

python dice_rolling_game.py

Run the tests

pip install pytest
pytest test_dice_rolling_game.py -v

Project Structure

Dice-Rolling-Game/
├── dice_rolling_game.py      # Main game logic
├── test_dice_rolling_game.py # Unit tests
├── requirements.txt          # Dependencies
├── .gitignore
└── README.md

Technologies Used

  • Python 3.10+
  • random (standard library)
  • pytest (testing)

What I Learned

  • Structuring code into reusable functions
  • Input validation with try/except
  • Writing unit tests with pytest and unittest.mock
  • Python docstrings and type hints

License

MIT License — see LICENSE for details.

Author

Sana MuqqadusLinkedIn · Fiverr

About

A Python program that simulates rolling a pair of dice. It allows users to choose how many dice to roll, display results, and tracks the number of rolls during the session.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages