DEV Community

m1chaelcodes
m1chaelcodes

Posted on • Edited on

That's Blackjack!

Python Blackjack program

Background

The final project of the CS101 course on CodeCademy asks the student to write a terminal game in Python. For this project I have chosen to create a simple game of Blackjack.

Summary

This is a very simple rendition of the classic casino banking game Blackjack. The dealer deals 2 cards to the player and 2 to itself. At the start of the round, the player can see both of their cards, but only 1 of the dealer's card. The player then can ask for another card ("hit") or reject another card ("stay").
The goal of the game is to hit 21 in the value of dealt cards. When this happens, the player has Blackjack. If the player goes over 21, they lose the game.
After the player's part is over, the dealer plays. The second of the dealer's cards is revealed at this point. If the total of the dealer's cards is less than 17, the dealer must "hit". If the dealer goes over 17, they must "stay". If the dealer hits Blackjack, the player loses. If the dealer goes over 21, the player wins.
At the end of the game, whoever has the highest card total wins.

Plans

I intend to come back to this program and spruce it up once my coding skills are a little more developed. The next step would be to include a betting system which provides the user a bit of money and allows to place a bet on their hand while maintaining the value of their money, gains, and losses.
I'd also like to set it up with ASCII art cards to represent the dealt hands, and make a bigger difference between the player's cards and the dealer's cards.

Source Code

The full program can viewed on GitHub.

Top comments (4)

Collapse
 
becry1944 profile image
Catherine R. Longoria

I want to share my experience of playing in online casinos. For me, one of the most exciting games is blackjack. This is an addictive game that requires not only luck, but also strategy.

As for the platform I prefer to play on, it's 1xbet login. Here I found a huge selection of different blackjack variations, ranging from classic to more exotic versions. Moreover, this platform provides great bonuses and promotions for players, which makes the game even more exciting.

Collapse
 
grommor profile image
Amir • Edited

Finding a good promo code can make all the difference when signing up for an online casino. I recommend find more is a great way to get a 200% deposit bonus, giving you more funds to play with. It’s an easy way to boost your balance and explore various games without risking too much of your own money.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.