technifyed

Programming · Python

Build a number guessing game in Python

Write a game where the computer picks a number and tells the player "higher" or "lower".

  • DifficultyBeginner
  • Estimated time1–3 hours
  • Budget₹0
  • ClassClass 6–11
  • TeamSolo
  • You needComputer only

Prerequisites: None; Python installed or an online Python editor

Original · by TechnifyedGameSoftware ProjectBeginner friendlyFree to doComputer onlyWell documented

My projects

Overview

The computer picks a random number from 1 to 100. The player guesses, the program answers higher or lower, and it counts the attempts. It uses every basic building block of programming in about 20 lines.

Why build this?

It is the best first program: short enough to finish in one sitting, and easy to extend one idea at a time.

What you will learn

  • How to use variables, loops and if statements together
  • How to generate random numbers
  • How to check user input so the program does not crash
  • How to break a problem into small steps

Skills you will use

ConditionalsInput handlingLoopsVariables

Materials and tools

  • Computer with Python 3, or a free online Python editor

Tools and software

Python

Expected cost₹0Nothing to buy
Estimated duration1–3 hours6 build steps, plus the report

Step-by-step roadmap

  1. Start

    You will finish with: a working game that reports the number of guesses and never crashes on bad input.

  2. 1

    Prerequisites

    Know this first: none; Python installed or an online Python editor. Then collect the 1 item in the materials list.

  3. 2

    Learn

    • How to use variables, loops and if statements together
    • How to generate random numbers
    • How to check user input so the program does not crash
    • How to break a problem into small steps
  4. 3

    Plan

    List the features for version one, sketch the screens or data flow and pick the tools. Keep the first version small.

  5. 4

    Build

    1. Import the random module and pick a secret number from 1 to 100.
    2. Ask the player for a guess and convert it to an integer.
    3. Compare it with the secret number and print "higher", "lower" or "correct".
    4. Put the question in a loop that ends when the guess is correct.
    5. Count the guesses and print the total at the end.
    6. Handle text input that is not a number without crashing.
  6. 5

    Test

    Type letters, a negative number and the right answer; the game should handle all three sensibly.

  7. 6

    Document

    Write a README: what it does, how to run it, screenshots and what you learned. Report structure

  8. 7

    Present

    Show a live demo of one complete task, then the design and the hardest problem you solved. Presentation structure · Viva questions

  9. 8

    Publish

    Put the code on GitHub with the README and, if you can, deploy a live demo.

Expected outcome

A working game that reports the number of guesses and never crashes on bad input.

Other versions of this project

Beginner version

Skip the input checking and limit the range to 1 to 10.

Advanced version

Add difficulty levels, a limited number of lives and a high-score file.

Research version

Compare the average guesses of a random strategy and binary search over 10,000 simulated games.

Portfolio version

Turn it into a small web or desktop game with a scoreboard and put the code on GitHub with a README.

Make this project better

  1. BasicSkip the input checking and limit the range to 1 to 10.
  2. This projectBuild a number guessing game in Python
  3. AdvancedAdd difficulty levels, a limited number of lives and a high-score file.
  4. ResearchCompare the average guesses of a random strategy and binary search over 10,000 simulated games.
  5. PortfolioTurn it into a small web or desktop game with a scoreboard and put the code on GitHub with a README.

Ways to do this project

Text marked "You write this" is a prompt for your own work; everything else is specific to this project.

Research question
You write thisOne question you can answer with data, narrow enough to finish in the time you have.
Hypothesis
You write thisWhat you expect to find, and why.
Variables
You write thisWhat you change or compare, what you measure, and what you hold constant.
Methodology
Compare the average guesses of a random strategy and binary search over 10,000 simulated games.
Data collection
You write thisSay what you will record, how many times, and how you will keep the records safe.
Analysis
You write thisChoose the table, chart or test that answers the question; report averages with their spread.
Limitations
You write thisList what could have affected the result: small sample, instrument limits, things you could not control.

Literature review

Find five to eight sources (your textbook, review articles, reports) and note what each says about your question. Group them by idea, not one after another, and end with what is still not known.

References

List every source you used in one style throughout (author, year, title, where it was published, link and the date you opened it).

Report and presentation

Report structure

  1. Title and summary
  2. Problem and target user
  3. Features
  4. Tools and technology
  5. Design: architecture, data model or screens
  6. Implementation
  7. Testing
  8. Results and screenshots
  9. Challenges
  10. Future improvements
  11. References

Presentation structure

  1. The problem
  2. Who it is for
  3. Live demo
  4. How it is built (one diagram)
  5. The hardest part
  6. Testing and results
  7. What you learned
  8. What comes next

Viva questions

Try answering before you open each one.

Why do you convert the input with int()?

input() returns text, and text cannot be compared with a number.

What is the best strategy for the player?

Binary search: always guess the middle of the remaining range.

What is the maximum guesses needed with that strategy for 1 to 100?

Seven.

What happens if the user types "abc"?

The program catches the ValueError and asks again.

Resources

Source and attribution

Original

Written by Technifyed. Free to use for your own school or college project; write the report in your own words. Added 1 Oct 2026.

Similar projects

More Programming projects

Programming · Python

Build a Snake game

Program the classic Snake with scoring, growing length and game over.

  • Easy
  • 2–7 days
  • Free
Game · Computer onlyView

Programming · Python

Make a to-do list app that saves to a file

Build a command-line task manager that adds, completes, deletes and saves tasks between runs.

  • Easy
  • 2–7 days
  • Free
Software Project · Computer onlyView

Programming · Python

Automate a boring task with a script

Write a script that renames and sorts a messy folder of files by type and date.

  • Easy
  • 2–7 days
  • Free
Software Project · Computer onlyView

Same tools

Cybersecurity + Pure Mathematics

Implement classic ciphers and break them

Write Caesar and substitution ciphers, then crack them with frequency analysis.

  • Easy
  • 2–7 days
  • Free
Software Project · Computer onlyView

Cybersecurity · Authentication

Build a password strength checker

Score a password's strength, explain why, and estimate how long it would take to guess.

  • Easy
  • 2–7 days
  • Free
Software Project · Computer onlyView

Data · Data Analytics

Explore a dataset and tell its story

Pick a public dataset, ask five questions of it and answer each with a chart.

  • Easy
  • 2–7 days
  • Free
Data Analysis · Computer onlyView

Artificial Intelligence · NLP

Build a rule-based chatbot for school FAQs

Answer common questions about your school with keyword matching and a fallback reply.

  • Easy
  • 2–7 days
  • Free
Software Project · Computer onlyView

Two-subject alternatives

Pure Mathematics + Programming

Visualise fractals with code

Draw the Koch snowflake, Sierpinski triangle and Mandelbrot set and measure a fractal dimension.

  • Intermediate
  • 2–7 days
  • Free
Visualization · Computer onlyView

Music, Theatre and Writing + Programming

Create generative art with code

Write programs that draw a different artwork every time they run and curate a series of ten.

  • Intermediate
  • 1–2 weeks
  • Free
Art Project · Computer onlyView

Same difficulty and budget

Software Development · Frontend

Build a pomodoro timer app

Make a 25-minute focus timer with breaks, sounds and a count of sessions done.

  • Beginner
  • 1 day
  • Free
Web App · Computer onlyView

Enter your email and the official page opens. Phone is optional.