Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Day-03-Dice-Roller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dice Roller

## 🧠 Behind the Scenes

- Uses Python's `random.randint()` to simulate dice rolls.
- Tracks the number of attempts.
- Simple loop until the correct number is guessed.

## 🚀 Getting Started

To play, just run the script in any Python 3 environment:

```bash
python dice_roller.py
22 changes: 22 additions & 0 deletions Day-03-Dice-Roller/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import random

def roll_dice(dice) :
return random.randint(1, dice)

print("Hello! You are playing the game Dice-Roller. Which was made in 15 minutes.\nYour goal: guess the number that will come up on the dice")

dice = int(input("Which cube do you want? "))
attempts = 0

while True:

x = int(input(f"Please enter a number between 1 and {dice}"))
dice_roller = roll_dice(dice)

if x==dice_roller :
print(f"Congratulations! You guessed the number on the dice in {attempts} moves")
break
else :
print("Sorry, you guessed wrong. Try again.")

attempts = attempts + 1