Skip to content

added Casino Game #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions Casino Game/Casino game.py
Original file line number Diff line number Diff line change
@@ -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