We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0b68a7 commit f72df54Copy full SHA for f72df54
Dice Rolling Game/Dice_Rolling.py
@@ -0,0 +1,32 @@
1
+import random
2
+
3
+def roll_dice():
4
+ return random.randint(1, 6)
5
6
+def ai_roll():
7
+ return roll_dice()
8
9
+def main():
10
+ print("Welcome to Dice Rolling AI!")
11
12
+ while True:
13
+ user_input = input("Press 'Enter' to roll the dice or 'q' to quit: ")
14
+ if user_input.lower() == 'q':
15
+ print("Thanks for playing!")
16
+ break
17
18
+ user_roll = roll_dice()
19
+ ai_roll_result = ai_roll()
20
21
+ print(f"You rolled: {user_roll}")
22
+ print(f"AI rolled: {ai_roll_result}")
23
24
+ if user_roll > ai_roll_result:
25
+ print("Congratulations! You won!")
26
+ elif user_roll < ai_roll_result:
27
+ print("AI wins! Better luck next time.")
28
+ else:
29
+ print("It's a tie!")
30
31
+if __name__ == "__main__":
32
+ main()
0 commit comments