ProjectsCore· 90 min read

Project: Build a Python Program

Put it together into a small, real, interactive program.

What you will learn

  • Combine variables, loops, functions and data
  • Handle user input
  • Build something complete

The brief

Build a small console program of your choice — a quiz, a to-do manager, a simple calculator, or a number-guessing game.

Example: number-guessing game

This little game ties together almost everything from the course — a module (random), a variable, a while loop, input, and if/elif decisions. The computer picks a secret number and the player keeps guessing until they get it.

A complete little game
import random

secret = random.randint(1, 10)
guess = 0

while guess != secret:
    guess = int(input("Guess (1-10): "))
    if guess < secret:
        print("Too low")
    elif guess > secret:
        print("Too high")

print("Correct! 🎉")

Here is the whole flow, step by step:

  1. import random brings in the random module so we can pick an unpredictable number.
  2. random.randint(1, 10) chooses a secret whole number from 1 to 10 and stores it in secret. We set guess = 0 just so the loop has something to compare on the very first check.
  3. The while guess != secret: loop keeps repeating as long as the guess is not equal to the secret (!= means “not equal”).
  4. Each turn, int(input(...)) asks the player for a number and converts their text into an integer.
  5. The if/elif then compares: if the guess is too small it prints Too low, if too big Too high. (If it is exactly right, neither runs — and the loop’s condition is now false.)
  6. Once the guess matches, the loop ends and the final line prints the congratulations message.

Note: Output (one example run): Guess (1-10): 5 Too low Guess (1-10): 8 Too high Guess (1-10): 7 Correct! 🎉 (The secret changes every time you play, so your run will differ.)

Tip: Start simple, get it working, then add features (a score, a limit on guesses, play-again).

✍️ Practice

  1. Build the guessing game (or your own idea) and run it.
  2. Add a feature of your own.

🏠 Homework

  1. Build a console to-do app: add, list and remove tasks in a loop.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →