Easy Games in Python

Python makes game development surprisingly accessible. With just the standard library and a couple of small modules, you can build playable games in under 100 lines of code each. In this guide, we build three classic games step by step — a Quiz Game, Pong, and the Snake Game – using Python and the turtle graphics library.

These projects reinforce core Python skills: variables, loops, conditionals, functions, and input handling. No external game engines or complex setup required.

TLDR

  • You can build fun games in Python using only the standard library — no pygame or external modules required
  • Each game project covers core Python concepts: variables, loops, conditionals, functions, and player input handling
  • Run Python game code from the terminal with python game_name.py after saving your .py file
  • Classic games like Quiz, Snake, Pong, and Hangman are great starting points for kids and beginners learning Python
  • For games needing graphics and sound, install pygame with pip install pygame — it works on Linux, Windows, and Mac

Game 1 | Quiz Game in Python

A quiz game requires zero external modules – just print(), input(), and if statements. The program stores questions, compares answers, tracks scores, and reports a final percentage.

questions = [
    ("What is the output of print(2 ** 3)?", "8"),
    ("Which keyword defines a function in Python?", "def"),
    ("What is the file extension for Python files?", "py"),
]

score = 0
print("Welcome to the Python Quiz!")

for question, answer in questions:
    print(f"Q: {question}")
    user_answer = input("Your answer: ").strip()
    if user_answer.lower() == answer.lower():
        print("Correct!")
        score += 1
    else:
        print(f"Wrong. The answer was: {answer}")

percentage = (score / len(questions)) * 100
print(f"You scored {score}/{len(questions)} — {percentage:.0f}%")

Game 2 | Pong in Python

Pong is the classic two-player arcade game. Each player controls a vertical paddle. A ball bounces off walls and paddles. Missing the ball scores a point for the opponent. We build this with the turtle module.

import turtle

player_a_score = 0
player_b_score = 0

window = turtle.Screen()
window.title("Pong Game")
window.bgcolor("black")
window.setup(width=800, height=600)
window.tracer(0)

# Paddles
left_paddle = turtle.Turtle()
left_paddle.speed(0)
left_paddle.shape("square")
left_paddle.color("white")
left_paddle.shapesize(stretch_wid=5, stretch_len=1)
left_paddle.penup()
left_paddle.goto(-350, 0)

right_paddle = turtle.Turtle()
right_paddle.speed(0)
right_paddle.shape("square")
right_paddle.color("white")
right_paddle.shapesize(stretch_wid=5, stretch_len=1)
right_paddle.penup()
right_paddle.goto(350, 0)

# Ball
ball = turtle.Turtle()
ball.speed(0)
ball.shape("circle")
ball.color("white")
ball.penup()
ball.goto(0, 0)
ball_dx = 0.15
ball_dy = 0.15

# Score display
score_pen = turtle.Turtle()
score_pen.speed(0)
score_pen.color("white")
score_pen.penup()
score_pen.hideturtle()
score_pen.goto(0, 260)
score_pen.write(f"Player A: {player_a_score}  |  Player B: {player_b_score}",
    align="center", font=("Arial", 24, "normal"))

def left_paddle_up():
    y = left_paddle.ycor()
    if y < 250: left_paddle.sety(y + 20)

def left_paddle_down():
    y = left_paddle.ycor()
    if y > -250: left_paddle.sety(y - 20)

def right_paddle_up():
    y = right_paddle.ycor()
    if y < 250: right_paddle.sety(y + 20)

def right_paddle_down():
    y = right_paddle.ycor()
    if y > -250: right_paddle.sety(y - 20)

window.listen()
window.onkeypress(left_paddle_up, "w")
window.onkeypress(left_paddle_down, "s")
window.onkeypress(right_paddle_up, "Up")
window.onkeypress(right_paddle_down, "Down")

while True:
    window.update()
    ball.setx(ball.xcor() + ball_dx)
    ball.sety(ball.ycor() + ball_dy)

    if ball.ycor() > 290:
        ball.sety(290)
        ball_dy *= -1
    if ball.ycor() < -290:
        ball.sety(-290)
        ball_dy *= -1

    if ball.xcor() > 390:
        ball.goto(0, 0)
        ball_dx *= -1
        player_a_score += 1
        score_pen.clear()
        score_pen.write(f"Player A: {player_a_score}  |  Player B: {player_b_score}",
            align="center", font=("Arial", 24, "normal"))

    if ball.xcor() < -390:
        ball.goto(0, 0)
        ball_dx *= -1
        player_b_score += 1
        score_pen.clear()
        score_pen.write(f"Player A: {player_a_score}  |  Player B: {player_b_score}",
            align="center", font=("Arial", 24, "normal"))

    if (340 < ball.xcor() < 350 and
            right_paddle.ycor() - 50 < ball.ycor() < right_paddle.ycor() + 50):
        ball.setx(340)
        ball_dx *= -1

    if (-350 < ball.xcor() < -340 and
            left_paddle.ycor() - 50 < ball.ycor() < left_paddle.ycor() + 50):
        ball.setx(-340)
        ball_dx *= -1

Game 3 | Snake Game in Python

The Snake game is the quintessential beginner project. A snake moves around eating food and growing longer. The game ends on self-collision or wall collision. We use turtle for graphics and random to place food.

import turtle
import random

SCREEN_WIDTH = 500
SCREEN_HEIGHT = 500
MOVE_DISTANCE = 20

DIRECTIONS = {
    "up":    (0, MOVE_DISTANCE),
    "down":  (0, -MOVE_DISTANCE),
    "left":  (-MOVE_DISTANCE, 0),
    "right": (MOVE_DISTANCE, 0)
}

snake = [[0, 0], [20, 0], [40, 0], [60, 0]]
current_direction = "up"

window = turtle.Screen()
window.title("Snake Game")
window.bgcolor("darkgreen")
window.setup(SCREEN_WIDTH, SCREEN_HEIGHT)
window.tracer(0)

pen = turtle.Turtle("square")
pen.color("lightgreen")
pen.penup()

food = turtle.Turtle()
food.shape("circle")
food.color("yellow")
food.penup()
food.shapesize(stretch_wid=0.5, stretch_len=0.5)

def reposition_food():
    x = random.randint(-SCREEN_WIDTH // 2 + 20, SCREEN_WIDTH // 2 - 20)
    y = random.randint(-SCREEN_HEIGHT // 2 + 20, SCREEN_HEIGHT // 2 - 20)
    food.goto(x, y)

reposition_food()

def draw_snake():
    pen.clearstamps()
    for segment in snake:
        pen.goto(segment[0], segment[1])
        pen.stamp()

def change_direction(new_dir):
    global current_direction
    opposites = {"up": "down", "down": "up", "left": "right", "right": "left"}
    if new_dir != opposites.get(current_direction):
        current_direction = new_dir

window.listen()
window.onkeypress(lambda: change_direction("up"), "Up")
window.onkeypress(lambda: change_direction("down"), "Down")
window.onkeypress(lambda: change_direction("left"), "Left")
window.onkeypress(lambda: change_direction("right"), "Right")

while True:
    window.update()
    head_x, head_y = snake[-1]
    dx, dy = DIRECTIONS[current_direction]
    new_head = [head_x + dx, head_y + dy]

    if new_head in snake[:-1]:
        snake = [[0, 0], [20, 0], [40, 0], [60, 0]]
        current_direction = "up"
        reposition_food()
        draw_snake()
        continue

    snake.append(new_head)

    if (abs(new_head[0] - food.xcor()) < 20 and
            abs(new_head[1] - food.ycor()) < 20):
        reposition_food()
    else:
        snake.pop(0)

    draw_snake()

window.mainloop()

Game 4 | Rock Paper Scissors in Python

Rock Paper Scissors is a hand game usually played between two people. The rules are simple: Rock beats Scissors, Scissors beats Paper, and Paper beats Rock. The program randomly selects one of the three options, and the user makes their choice via keyboard input.

import random

choices = ["rock", "paper", "scissors"]

print("Rock Paper Scissors!")
print("Enter rock, paper, or scissors. Type 'quit' to exit.")

user_score = 0
cpu_score = 0

while True:
    user_choice = input("Your choice: ").strip().lower()
    if user_choice == "quit":
        print(f"\nFinal Score — You: {user_score} | CPU: {cpu_score}")
        print("Thanks for playing!")
        break
    if user_choice not in choices:
        print("Invalid choice. Try again.")
        continue

    cpu_choice = random.choice(choices)
    print(f"CPU chose: {cpu_choice}")

    if user_choice == cpu_choice:
        print("It's a tie!")
    elif (user_choice == "rock" and cpu_choice == "scissors") or \
         (user_choice == "scissors" and cpu_choice == "paper") or \
         (user_choice == "paper" and cpu_choice == "rock"):
        print("You win this round!")
        user_score += 1
    else:
        print("CPU wins this round!")
        cpu_score += 1

    print(f"Score — You: {user_score} | CPU: {cpu_score}")

Game 5 | Hangman in Python

Hangman is a classic word guessing game. One player thinks of a word, and the other tries to guess it letter by letter. Each wrong guess brings the hangman drawing one step closer to completion. We use the random module to pick a word and a list to track guessed letters.

import random

words = ["python", "developer", "hangman", "keyboard", "monitor"]
word = random.choice(words)
guessed = []
tries = 6

print("Hangman!")
print(f"The word has {len(word)} letters.")

while tries > 0:
    display = "".join([letter if letter in guessed else "_" for letter in word])
    print(f"Word: {display}")
    print(f"Tries left: {tries}")
    print(f"Guessed letters: {', '.join(sorted(guessed)) if guessed else 'None'}")

    guess = input("Guess a letter: ").strip().lower()

    if len(guess) != 1 or not guess.isalpha():
        print("Enter a single alphabet letter.")
        continue

    if guess in guessed:
        print("You already guessed that letter.")
        continue

    guessed.append(guess)

    if guess in word:
        print(f"Good guess! '{guess}' is in the word.")
        if all(letter in guessed for letter in word):
            print(f"Congratulations! You guessed the word: {word}")
            break
    else:
        tries -= 1
        print(f"Wrong! '{guess}' is not in the word.")

if tries == 0:
    print(f"Game over! The word was: {word}")

Game 6 | Tic-Tac-Toe in Python

Tic-Tac-Toe is a two-player grid game where each player marks a 3×3 grid with X or O. The first player to get three marks in a row, column, or diagonal wins. This version uses a numbered grid for input and checks all eight winning combinations after every move.

def print_board(board):
    print()
    for i in range(3):
        print(f" {board[i*3]} | {board[i*3+1]} | {board[i*3+2]} ")
        if i < 2:
            print("---|---|---")
    print()

def check_win(board, player):
    wins = [(0,1,2),(3,4,5),(6,7,8),
            (0,3,6),(1,4,7),(2,5,8),
            (0,4,8),(2,4,6)]
    return any(board[a] == board[b] == board[c] == player for a,b,c in wins)

board = [" "] * 9
players = ["X", "O"]
turn = 0

print("Tic-Tac-Toe! Positions 1-9:")
print_board([str(i+1) for i in range(9)])

while True:
    current = players[turn % 2]
    print(f"Player {current}'s turn.")
    pos = input("Choose position (1-9): ").strip()

    if not pos.isdigit() or pos not in ["1","2","3","4","5","6","7","8","9"]:
        print("Invalid input.")
        continue

    idx = int(pos) - 1
    if board[idx] != " ":
        print("That spot is taken.")
        continue

    board[idx] = current
    print_board(board)

    if check_win(board, current):
        print(f"Player {current} wins!")
        break
    elif " " not in board:
        print("It's a draw!")
        break

    turn += 1

Game 7 | Number Guessing Game in Python

In this game the computer picks a random number within a range, and the player tries to guess it. After each guess the program responds with “too high” or “too low”, narrowing the range until the correct number is found. It teaches input validation and conditional logic while being easy to understand.

import random

lower = 1
upper = 100
secret = random.randint(lower, upper)
attempts = 0

print("Number Guessing Game!")
print(f"I am thinking of a number between {lower} and {upper}.")

while True:
    guess = input(f"Enter your guess ({lower}-{upper}): ").strip()

    if not guess.isdigit():
        print("Enter a valid number.")
        continue

    guess = int(guess)
    attempts += 1

    if guess < secret:
        print("Too low! Try again.")
        lower = max(lower, guess + 1)
    elif guess > secret:
        print("Too high! Try again.")
        upper = min(upper, guess - 1)
    else:
        print(f"Correct! The number was {secret}.")
        print(f"You guessed it in {attempts} attempt{'s' if attempts != 1 else ''}!")
        break

Game 8 | Mad Libs Generator in Python

Mad Libs is a word game where one player asks for a list of words to substitute for blanks in a story before reading aloud the final result. The humor comes from the often unexpected results. This program uses simple input() calls and f-string formatting to build the story.

print("Mad Libs Generator!")
print("Answer the prompts to create a silly story.")

adjective1 = input("Enter an adjective: ")
noun1 = input("Enter a noun: ")
verb1 = input("Enter a verb (past tense): ")
adverb1 = input("Enter an adverb: ")
adjective2 = input("Enter another adjective: ")
animal = input("Enter an animal: ")
verb2 = input("Enter a verb: ")
exclamation = input("Enter an exclamation (e.g. 'Wow!'): ")

story = f"""
Yesterday, I went to a {adjective1} zoo and saw a {noun1}.
It {verb1} {adverb1} past the visitors.
Suddenly, a {adjective2} {animal} began to {verb2}!
{exclamation} I could not believe my eyes!
"""

print("\n--- Your Mad Libs Story ---")
print(story)

Game 9 | Dice Roll Simulator in Python

A dice roll simulator mimics the action of rolling physical dice. Each die has six faces numbered 1 through 6, chosen at random. The program simulates one or more dice rolls and can keep a running tally of results across many rolls.

import random

def roll_dice(num_dice=1):
    return [random.randint(1, 6) for _ in range(num_dice)]

print("Dice Roll Simulator!")
print("Roll 1 die, 2 dice, or any number you like.")

total_rolls = 0
roll_history = []

while True:
    cmd = input("Roll (or 'count' to see stats, 'quit' to exit): ").strip().lower()

    if cmd == "quit":
        print(f"\nYou rolled {total_rolls} time(s) in total.")
        print("Goodbye!")
        break

    if cmd == "count":
        if not roll_history:
            print("No rolls recorded yet.")
            continue
        print(f"\nTotal rolls: {total_rolls}")
        print("Roll history:", roll_history)
        print(f"Grand total of all rolls: {sum(roll_history)}")
        continue

    if cmd.isdigit():
        num = int(cmd)
        if num < 1 or num > 100:
            print("Choose a number between 1 and 100.")
            continue
        results = roll_dice(num)
        print(f"Rolling {num} die(s)... {results}")
        print(f"Sum: {sum(results)}")
        roll_history.extend(results)
        total_rolls += num
    else:
        print("Enter a number, 'count', or 'quit'.")

Game 10 | Word Scramble Game in Python

A word scramble shuffles the letters of a word to produce a jumbled string. The player must unscramble the letters to guess the original word. We use the random module to shuffle letters and a small word list to keep the game self-contained.

import random

words = ["python", "hangman", "scramble", "turtle", "loop", "function"]
score = 0

print("Word Scramble Game!")
print("Unscramble the letters to guess the word.")
print("Type 'hint' for a clue, or 'skip' to pass.")

while words:
    original = random.choice(words)
    words.remove(original)

    letters = list(original)
    random.shuffle(letters)
    scrambled = "".join(letters)

    print(f"Scrambled: {scrambled.upper()}")
    attempts = 3

    while attempts > 0:
        guess = input("Your guess: ").strip().lower()

        if guess == "skip":
            print(f"The word was: {original}")
            break
        elif guess == "hint":
            print(f"Hint: starts with '{original[0]}' and ends with '{original[-1]}'")
            attempts -= 1
            print(f"Attempts left: {attempts}")
            continue

        if guess == original:
            print("Correct!")
            score += attempts
            break
        else:
            attempts -= 1
            print(f"Wrong! Attempts left: {attempts}")
    else:
        print(f"The word was: {original}")

print(f"Game over! Your total score: {score}")

Frequently Asked Questions

Can I code a game in Python?

Yes. Python is one of the easiest languages for building your own games. You can start with text-based games using only print() and input(), then move to graphical games using the built-in turtle module or install pygame via pip install pygame.

What is the easiest game to code in Python?

A number guessing game or a Quiz Game are the easiest starting points. Both require under 50 lines of code, use only built-in functions, and teach you core concepts like loops, conditionals, and player input.

Can Python make AAA games?

Not competitively. AAA studios use C and C++ for performance-critical game engines. Python works fine for prototyping, scripting game logic, or building indie titles, but it is not the right tool for graphically intensive commercial games.

Is C or Python easier?

Python is significantly easier. C requires manual memory management, explicit data type declarations, and a compilation step. Python reads almost like English, handles memory automatically, and runs without a build step.

Does NASA use Python or C?

Both, but Python is widely used at NASA for automation scripts, data analysis, and flight software prototyping. C is used for real-time and safety-critical systems where performance is paramount.

What language do most AAA games use?

Most AAA games are built with C and C++. Game engines like Unreal and Unity are written in C++, with Lua and Python commonly used for game scripting and logic.

Should I learn Python or C as a beginner?

Start with Python. You will write working code within hours instead of days, and the concepts you learn transfer directly to other languages including C.

How do I run a Python game from the terminal?

Save your code in a .py file, open your terminal, navigate to the folder, and run python game_name.py. On Linux and Mac, use python3 if python defaults to Python 2.

Siddhi Sawant
Siddhi Sawant
Articles: 16