Card game in Python

Haseeb Zeeshan
2 min readOct 17, 2021

--

Welcome to the tutorial. In this tutorial, we are going to be making a card game in python.

How to play?

You have 30 cards in a deck, 10 cards are black, 10 are yellow and 10 are red, note that each card has a number from 0–10, this makes them unique from all the other cards in the set. First, shuffle all the cards in the deck. Then each player must take 1 card each from the top of the deck and compare the colours to see which player wins the round. When you win a round, you take the other person’s card as well as keeping your card.

Rules of the game:

Red vs Black = Red Wins

Yellow vs Red = Yellow Wins

Black vs Yellow = Black Wins

And if the colours are the same, then check the number to see which player has the higher number, there cannot be a tie, because the number cannot be the same if it’s the same colour.

The Flowchart for the program:

The Pseudocode for the program:

The actual code for the program:

Final thoughts:

As you can see you have made your own card game, whenever I finally finish a program, I feel a sense of accomplishment, and hopefully, you do also. The point of this tutorial is to not only help you learn but to let you enjoy learning while you do it, as well as making a game to play whenever you’re bored.

--

--

Haseeb Zeeshan

I’m an inquisitive person who likes to experiment with Python. My tutorials can be found at https://www.haseebzeeshan.com/