Back to Projects

Coding

My First Python Program

Write a simple quiz game and see how code can turn your ideas into something interactive.

Easy · 1 hour

My First Python Program

Introduction

Coding is like giving super-clear instructions to a computer so it can do something amazing for you.

This project is fun because you will create a real program that asks questions, keeps score, and talks back to the player.

The Why

Computer programs follow instructions one step at a time. Python uses commands like `print()` to show messages, `input()` to collect answers, and variables to remember information such as a score.

Step-by-Step Instructions

  1. 1

    Open a beginner-friendly Python editor online and start a new project.

  2. 2

    Type a `print()` line to welcome the player to your quiz game.

  3. 3

    Make a score variable and set it to 0 so your game can count points.

  4. 4

    Use `input()` to ask the player a question and store the answer in a variable.

  5. 5

    Add an `if` statement to check whether the answer is correct.

  6. 6

    Increase the score when the player gets a question right, then show the new score with `print()`.

  7. 7

    Run your program, test it, and fix any mistakes until your quiz works smoothly.

The four building blocks

These are the only Python commands you need to build a working quiz game.

print()
Shows text on screen. Try: print("Hello!") — the computer displays exactly what is inside the quotes.
print("Welcome to my quiz!")
input()
Pauses the program and waits for the user to type something. The answer is stored in a variable so you can check it later.
answer = input("What is 2 + 2? ")
variables
A named container that holds a value. You can change what is inside it during the program — perfect for keeping score.
score = 0
if statements
Lets the program make a decision. If a condition is true, run one block of code. If not, skip it or do something else.
if answer == "4":
    score = score + 1

A complete example

Copy this into Replit or Trinket and run it. Then modify the question to make it your own.

score = 0

print("Welcome to my quiz!")

answer = input("What is the capital of France? ")
if answer.lower() == "paris":
    score = score + 1
    print("Correct!")
else:
    print("Not quite — it's Paris.")

print("Your score:", score, "out of 1")