Created
December 16, 2020 19:26
-
-
Save zemmyang/8da1b85acd64f483d1c82a4725e004c0 to your computer and use it in GitHub Desktop.
Simple Betting Game in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def intro_banner(): | |
| s = "Welcome to the Game!" | |
| print(s) | |
| def game_over(): | |
| s = "Game Over. Bye!" | |
| print(s) | |
| def main(): | |
| intro_banner() | |
| playername = input('Player Name >> ') | |
| money = 50 | |
| print("Welcome to the game, " + playername + ". Your starting amount is " + str(money) + ' Gold.') | |
| keepplaying = True | |
| while keepplaying: | |
| bet = input("Place your bet >> ") | |
| isbetnotvalid = int(bet) > money or int(bet) < -1 | |
| while isbetnotvalid: | |
| print("Please enter a valid bet.") | |
| bet = input("Place fix your bet >> ") | |
| isbetnotvalid = int(bet) > money or int(bet) < -1 | |
| bet = int(bet) | |
| player_card = random.randint(1, 12) | |
| cpu_card = random.randint(1, 12) | |
| print("Your card is " + str(player_card) + ". CPU card is " + str(cpu_card) + ".") | |
| if player_card == cpu_card: | |
| print("It's a DRAW! CPU wins because that's how it is.") | |
| money = money - bet | |
| elif player_card > cpu_card: | |
| print("You win " + str(bet) + " Gold!") | |
| money = money + bet | |
| else: | |
| print("CPU wins! You lose " + str(bet) + " Gold!") | |
| money = money - bet | |
| if money < 0: | |
| print("You're out of money!") | |
| game_over() | |
| keepplaying = False | |
| else: | |
| print("Your money is now " + str(money) + " Gold.") | |
| ask = input("Do you want to keep playing? [y/N] >> ") | |
| if ask == 'y' or ask == 'Y': | |
| keepplaying = True | |
| else: | |
| print("You're leaving with " + str(money) + " Gold. Bye.") | |
| game_over() | |
| keepplaying = False | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Honestly, trying to figure out which betting strategies actually work can get really confusing, especially with so many casinos and apps promising big wins. I wasted a lot of time on platforms that looked fancy but were impossible to navigate. What actually helped me was pari-app-match.in — it’s simple, easy to use, and gives a real sense of how different approaches play out. I’ve tried a few casinos and betting setups through it, and it made understanding patterns way less stressful. Honestly, it changed how I approach online betting without overthinking every single bet.