From 9541724e8fd2dd5ce381b713e97a8515c9980d69 Mon Sep 17 00:00:00 2001 From: VedantAdke96 <92367832+VedantAdke96@users.noreply.github.com> Date: Fri, 5 May 2023 18:06:21 +0530 Subject: [PATCH] added Casino Game --- Casino Game/Casino game.py | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Casino Game/Casino game.py diff --git a/Casino Game/Casino game.py b/Casino Game/Casino game.py new file mode 100644 index 0000000..605aa5e --- /dev/null +++ b/Casino Game/Casino game.py @@ -0,0 +1,47 @@ +# Gambling game! + +import random + +while(True): + # Intoduction + print("Welcome to virtual casino!") + userName = input("Enter your name to continue: ").capitalize() + depositAmount = int(input(f"{userName}, enter amount to deposit for playing: $")) + input("Press any key to continue...\n") + + #Winning number + winningNum = random.randint(1,10) + + # Rules of game! + print("RULES!\n") + print("Rule 1: You have to choose any number between 1 to 10.") + print("Rule 2: If you choose the right number, you will get 10x the money you bet.") + print("Rule 3: If you choose the wrong number, you will loose the amount you bet.\n") + + # Start of the game! + print("Your current balance is $", depositAmount) + betMoney = int(input("Choose amount of money to bet: $")) + if betMoney > depositAmount: + raise Exception("Error! You don't have enough balance!") + + userNum = int(input("Choose an number between 1 and 10: ")) + + if userNum == winningNum: + winAmount = betMoney * 10 + updatedMoney = depositAmount + winAmount + print("Congratulations! You have chosen the right number!") + print(f"You won {winAmount}$") + print(f"{userName}, your balance is now ${updatedMoney}") + + elif userNum != winningNum: + lostAmount = depositAmount - betMoney + print(f"Bad luck! You lost ${betMoney}") + print(f"The winning number was {winningNum}") + print(f"{userName}, your balance is now ${lostAmount}") + + playAgain = input("Do you want to play again? y/n: ") + if playAgain == 'y' or playAgain == 'yes': + continue + else: + print("Thanks for playing our game.") + break