Day 011 of the 100 Days of Python challenge brings together the previous lessons in a command-line Blackjack game. The player competes against a computer dealer using random cards and standard score comparisons.

Project Overview

The program represents cards as numbers. Number cards keep their values, face cards are represented by 10, and an ace starts as 11. The deal_card() function chooses one card at random from the deck list.

The calculate_score() function handles two important rules: a two-card total of 21 is Blackjack, represented internally by 0, and an ace changes from 11 to 1 when a hand would otherwise exceed 21.

if sum(cards) == 21 and len(cards) == 2:
    return 0
if 11 in cards and sum(cards) > 21:
    cards.remove(11)
    cards.append(1)

The player can draw cards until passing or going over 21. The dealer then draws until reaching at least 17. A separate compare() function decides whether the result is a win, loss, or draw.

Game Statistics

The program tracks wins, losses, and draws across multiple rounds using module-level counters. After each game, it displays the current totals and asks whether the player wants to play again.

The logo is kept in a separate art.py module, which keeps the main game file focused on behavior rather than presentation assets.

What This Project Teaches

Day 011 practices lists, functions, loops, conditionals, random selection, mutable game state, module imports, and handling special cases. It is also a useful example of breaking a larger program into smaller functions such as deal_card(), calculate_score(), compare(), and play_game().

Running the Project

cd 100daysofpython/day011
python main.py

The project requires the supporting art.py file in the same folder. View the Day 011 source code on GitHub.