1
Home
Tirsvad edited this page 2026-11-15 10:18:04 +01:00

English · Dansk · Bahasa Melayu

Blackjack

A console Blackjack game: play against the computer dealer with emoji cards and try to get closer to 21 than the dealer.

What is it?

Day 11 of the Udemy course 100 Days of Code: The Complete Python Pro Bootcamp. You and the computer dealer each get two cards, shown as emoji. You choose to draw another card (y) or to pass (n), then the dealer draws while its score is below 17 and the program tells you who won. Afterwards you can play again. The deck is unlimited, a jack, queen or king counts 10, an ace counts 11 or 1, and an ace with a ten-card in the first two cards is a blackjack.

What the exercise teaches

  • Writing small functions with parameters and return values
  • Keeping the game rules as pure functions apart from console input and output, so they can be tested
  • Using lists, loops and conditions to deal cards, score a hand and let the dealer play
  • Keeping texts and numbers in constants and writing small automated tests

What it does

  • One player against a computer dealer with an unlimited deck
  • Emoji cards and the course's ASCII logo at the start of every game
  • Ace counts 11 or 1, and a two-card ace with a ten-card is a blackjack
  • The dealer draws while its score is below 17
  • Invalid answers are asked for again, and you can play again after each game

Next