diff --git a/Day-03-Dice-Roller/README.md b/Day-03-Dice-Roller/README.md new file mode 100644 index 0000000..7b52fc6 --- /dev/null +++ b/Day-03-Dice-Roller/README.md @@ -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 diff --git a/Day-03-Dice-Roller/main.py b/Day-03-Dice-Roller/main.py new file mode 100644 index 0000000..114c831 --- /dev/null +++ b/Day-03-Dice-Roller/main.py @@ -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 \ No newline at end of file