Code Monsters Academy
Home › Blog
Copy and paste

Python Games Code to Copy and Paste (8 Small Games)

Published 2026-11-21

Short answer. Every game on this page uses plain Python with nothing extra to install, not even pygame. Copy the code, paste it into any Python editor, including one in a browser tab, and press Run. They work on school laptops, Chromebooks and iPads.

When you are learning to code, a blank editor is the hardest thing to face. Starting from a game that already works is much easier, because you can see what each line does and then start changing things. That is what this page is for. Each of the eight games below is short enough to paste and run in a few seconds, and each one is followed by a note on what it teaches and one change to try.

The change is the important part. Copying code teaches you very little on its own, but copying it, running it and then changing one number to see what happens teaches you a great deal.

1. Guess the number

import random

answer = random.randint(1, 10)
tries = 0
while True:
    guess = int(input("Guess 1-10: "))
    tries += 1
    if guess == answer:
        print("Correct in", tries, "tries!")
        break
    print("Higher" if guess < answer else "Lower")

The computer picks a secret number from 1 to 10, and you keep guessing until you get it, with a hint after each wrong guess. It teaches the while True loop, which keeps going until break tells it to stop, and the random module. Try changing the 10 to 100 and see how many guesses it takes. Seven guesses is only a useful upper bound if you deliberately use the higher/lower hints to split the remaining range roughly in half.

2. Rock, paper, scissors

import random

options = ["rock", "paper", "scissors"]
cpu = random.choice(options)
you = input("rock, paper or scissors? ").lower()
print("Computer chose", cpu)
if you == cpu:
    print("Draw")
elif (you, cpu) in [("rock","scissors"), ("paper","rock"), ("scissors","paper")]:
    print("You win")
else:
    print("Computer wins")

You type your choice, the computer picks at random, and the program decides who won. The interesting line is the one with three pairs in brackets, which lists every way you can win so the program does not need a long chain of if statements. Try adding a loop around the whole thing so you can play best of five.

3. Dice roller

import random

rolls = [random.randint(1, 6) for _ in range(5)]
print("Rolls:", rolls)
print("Total:", sum(rolls))

This rolls five dice and adds them up. It is the shortest game here, and it shows off sum(), which adds up everything in a list for you. Change the 6 to 20 to roll the kind of dice used in tabletop games, or change the 5 to roll more of them.

4. Word jumble

import random

word = "monster"
letters = list(word)
random.shuffle(letters)
print("Unjumble:", "".join(letters))
guess = input("Your answer: ")
print("Yes!" if guess.lower() == word else "It was " + word)

The program scrambles a word and asks you to unscramble it. It turns the word into a list of letters, shuffles them, and joins them back together. Replace "monster" with any word you like and try it on someone else in the family.

5. Quiz with a score

questions = [
    ("What is 7 x 8?", "56"),
    ("Which planet is closest to the Sun?", "mercury"),
    ("How many legs does a spider have?", "8"),
]
score = 0
for q, a in questions:
    if input(q + " ").strip().lower() == a:
        score += 1
print("Score:", score, "of", len(questions))

Each question is stored together with its answer, and a for loop asks them one by one and keeps score. Notice the .strip().lower() after input, which removes any extra spaces and makes the answer lowercase, so typing "Mercury" with a capital M still counts. The best change here is to replace the questions with your own, perhaps about a subject you are revising for school.

6. A text adventure with three rooms

rooms = {
    "hall": {"north": "kitchen", "east": "garden"},
    "kitchen": {"south": "hall"},
    "garden": {"west": "hall"},
}
here = "hall"
while True:
    print("You are in the", here, "| exits:", ", ".join(rooms[here]))
    move = input("Go (or quit): ").lower()
    if move == "quit":
        print("Thanks for playing!")
        break
    if move in rooms[here]:
        here = rooms[here][move]
    else:
        print("No exit that way")

You move between a hall, a kitchen and a garden by typing directions, and type quit when you have had enough. The map is stored in a dictionary, where each room lists the exits it has and where they lead. This is the first program on the page that has to remember where you are. Try adding a fourth room, perhaps a cellar below the kitchen, by adding a new entry and a "down" exit.

7. Countdown timer

import time

for n in range(5, 0, -1):
    print(n)
    time.sleep(1)
print("Go!")

This counts down from five, pausing a second between numbers, then prints Go. The range(5, 0, -1) counts backwards, because the third number is how much to change by each time. Try changing the 1 inside time.sleep to 0.5 to make it twice as fast.

8. Multiplication drill

import random

score = 0
for _ in range(5):
    a, b = random.randint(2, 9), random.randint(2, 9)
    if int(input(f"{a} x {b} = ")) == a * b:
        score += 1
print("You got", score, "out of 5")

Five random times-table questions, with a score at the end. It is a good one for younger brothers and sisters to play once you have written it. To make it harder, change the 9s to 12s, or change the 5 in range(5) to 10 for a longer round.

How to use these with a child

Before pressing Run, read the code out loud together and guess what it will do. Then run it and see whether you were right. That small habit of predicting first is one of the most effective ways to learn programming, and it is the first step of a teaching approach called PRIMM that has been trialled in schools (Computer Science Education, 2019).

After that, change one thing at a time, such as a number, a word or a range, and predict the result again. Then break the program on purpose by deleting a quote or a bracket and reading the error message, so that errors become familiar rather than frightening. Finally, encourage your child to borrow pieces. The quiz in game five can become a quiz about their favourite football team in five minutes, and that is when it starts to feel like their own program.

Questions people ask

Can I copy and paste these Python games?

Yes. Every example uses only what comes with Python, so it runs in any Python 3 editor, including one in a web browser. Copy the block, run it, then change a value.

Do these games need pygame?

No. They are text-based on purpose, so they can run in a Python 3 environment without graphical libraries. On a Chromebook, school laptop or iPad, the exact result depends on whether the chosen editor supports interactive input().

What age are these games for?

Around nine and up for the first few. The quiz and the text adventure suit eleven and up. Younger children enjoy changing the numbers alongside an adult.

Start with a game instead of a blank editor

Code Monsters Academy teaches the same building blocks, which are variables, loops, conditions and lists, inside a game, one five-minute level at a time. There is nothing to install, chapters 1 and 2 are free without signing up, and chapters 1–3 is free once you log in.

Play with code

Related reading: 8 project ideas, lists for beginners and for vs while.

Python code games to copy and paste: quick answers

Can I copy and paste random Python code into a game?

Yes. Every example on this page is a complete program: copy the block, paste it into a .py file, run it with python filename.py. No pygame, no pip install.

What is the shortest Python game code to copy and paste?

The guessing game below is about 10 lines. It is the fastest way to get a playable Python game running, and you can change the number range in one line.

Where can I find computer coding Python projects for kids?

Start with these 8 small games, then continue inside Code Monsters Academy, where each level teaches one Python concept through a battle.