Uno Bank – Card Game (using Python)


Are you ready to test your luck and strategy with a Python twist on the classic Uno card game? In Uno Bank, you’ll start with $10 in your virtual bank and 10 card draws. Your goal? Maximize your bank balance by drawing cards that either add to or subtract from your total. But beware—some cards can double your money, halve it, or even change the number of draws you have left!

This challenge is perfect for Python beginners and enthusiasts who want to practice their programming skills while having fun. Let’s dive into the rules, the logic, and how you can build this game yourself.

Game Rules

Game Objective
Start with $10 and 10 draws. Draw cards to increase your bank balance. The game ends when you run out of draws, and your final balance is displayed.

Card Types and Effects

Green Cards: Increase your bank balance by the amount on the card (e.g., +3$).

Blue Cards: Decrease your bank balance by the amount on the card (e.g., -4$).

Black Cards:

  • x2: Double your current bank balance.
  • /2: Halve your current bank balance.
  • +2: Gain 2 extra draws.
  • -2: Lose 2 draws.

How to Build the Game in Python

Step 1: Set Up the Deck
Create a deck of cards with the following distribution:

    Green Cards: 4 cards (+1$, +3$, +5$, +7$)
    Blue Cards: 4 cards (-2$, -4$, -6$, -8$)
    Black Cards: 4 cards (x2, /2, +2, -2)

You can use a list to represent the deck and shuffle it at the start of the game.

Step 2: Initialise the Game

    Start with a bank balance of $10.
    Start with 10 draws.

Step 3: Game Loop

    Draw a Card: Randomly select a card from the deck.
    Apply the Effect:

      If it’s a green card, add the amount to the bank.
      If it’s a blue card, subtract the amount from the bank.
      If it’s a black card, apply the special effect (double, halve, or change the number of draws).

    Update Draws: Decrease the number of draws by 1 (unless a +2 or -2 card is drawn).
    Repeat until no draws are left.

Step 4: Display the Result
Once all draws are used, display the final bank balance.

Python Code

Complete the code for this Uno-Bank game using our online Python IDE:

Extension Task: 2-Player Mode!

Ready to take Uno Bank to the next level? In this two-player extension, you and a friend will compete to maximise your bank balances by drawing cards from a shared deck. The rules remain similar, but now, you will take turns drawing cards, and a new set of yellow cards introduces exciting (and sometimes brutal) interactions between players!

New Rules for Two-Player Mode

Objective
Both players start with $10 and 10 draws. Players take turns drawing one card at a time. The game ends when one of the players have used all their draws. The player with the highest bank balance wins!

New Cards
The game uses the same cards as before plus an extra 4 yellow cards:

  • Swap Card: Both players swap their bank balances.
  • Forward Card: Give all your money to the other player.
  • Backward Card: Take all the money from the other player.
  • Bomb Card: Your bank balance resets to $0.
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!