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
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
Materials and tools
- Computer with Python 3, or a free online Python editor
Tools and software
Step-by-step roadmap
Start
You will finish with: a working game that reports the number of guesses and never crashes on bad input.
- 1
Prerequisites
Know this first: none; Python installed or an online Python editor. Then collect the 1 item in the materials list.
- 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
- 3
Plan
List the features for version one, sketch the screens or data flow and pick the tools. Keep the first version small.
- 4
Build
- Import the random module and pick a secret number from 1 to 100.
- Ask the player for a guess and convert it to an integer.
- Compare it with the secret number and print "higher", "lower" or "correct".
- Put the question in a loop that ends when the guess is correct.
- Count the guesses and print the total at the end.
- Handle text input that is not a number without crashing.
- 5
Test
Type letters, a negative number and the right answer; the game should handle all three sensibly.
- 6
Document
Write a README: what it does, how to run it, screenshots and what you learned. Report structure
- 7
Present
Show a live demo of one complete task, then the design and the hardest problem you solved. Presentation structure · Viva questions
- 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
- BasicSkip the input checking and limit the range to 1 to 10.
- This projectBuild a number guessing game in Python
- AdvancedAdd difficulty levels, a limited number of lives and a high-score file.
- ResearchCompare the average guesses of a random strategy and binary search over 10,000 simulated games.
- 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).
Use this as the outline of your README or case study.
- Problem
- The computer picks a random number from 1 to 100.
- Why it matters
- It is the best first program: short enough to finish in one sitting, and easy to extend one idea at a time.
- What was built
- A working game that reports the number of guesses and never crashes on bad input.
- Technology
- Python
- Architecture
- You write thisOne diagram: the parts and how data moves between them.
- Implementation
- You write thisThe 6 build steps in your own words, with one code or design decision you are proud of.
- Challenges
- You write thisThe hardest bug or decision, and how you got past it.
- Results
- Type letters, a negative number and the right answer; the game should handle all three sensibly.
- Demo and code
- You write thisA link to a live demo or a short video, and to the GitHub repository.
- Lessons learned
- You write thisWhat you would do differently next time.
- Future improvements
- Add difficulty levels, a limited number of lives and a high-score file.
- Problem
- The computer picks a random number from 1 to 100.
- Target user
- You write thisOne specific person: who they are and when they would use this.
- Solution
- Write a game where the computer picks a number and tells the player "higher" or "lower".
- First version (MVP)
- A loop that accepts guesses and says higher or lower.
- Tech stack
- Python
- Architecture
- You write thisA quick sketch of the parts and how they connect.
- Demo
- Type letters, a negative number and the right answer; the game should handle all three sensibly.
- Stretch goals
- Add difficulty levels, a limited number of lives and a high-score file.
Team roles
Plan by length
24-hour
- Hours 0–2: agree the problem, the user and the one thing the demo must show
- Hours 2–16: build only the first version
- Hours 16–20: test the demo path end to end and fix what breaks
- Hours 20–24: slides, a 2-minute demo script and a backup recording
48-hour
- Evening 1: problem, user, sketch and task split
- Day 1: first version working end to end
- Day 2 morning: one stretch goal and testing
- Day 2 afternoon: polish, slides and demo practice
1-week
- Day 1: research the problem and talk to two possible users
- Days 2–4: first version
- Day 5: stretch goals
- Day 6: testing and write-up
- Day 7: demo video and presentation
Report and presentation
Report structure
- Title and summary
- Problem and target user
- Features
- Tools and technology
- Design: architecture, data model or screens
- Implementation
- Testing
- Results and screenshots
- Challenges
- Future improvements
- References
Presentation structure
- The problem
- Who it is for
- Live demo
- How it is built (one diagram)
- The hardest part
- Testing and results
- What you learned
- 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.
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.
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.
Programming · Python
Build a calculator with a graphical interface
Make a desktop calculator with buttons, a display and keyboard support.
Same tools
Cybersecurity + Pure Mathematics
Implement classic ciphers and break them
Write Caesar and substitution ciphers, then crack them with frequency analysis.
Cybersecurity · Authentication
Build a password strength checker
Score a password's strength, explain why, and estimate how long it would take to guess.
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.
Artificial Intelligence · NLP
Build a rule-based chatbot for school FAQs
Answer common questions about your school with keyword matching and a fallback reply.
Two-subject alternatives
Pure Mathematics + Programming
Visualise fractals with code
Draw the Koch snowflake, Sierpinski triangle and Mandelbrot set and measure a fractal dimension.
Pure Mathematics + Programming
Map your school as a graph and find shortest paths
Model corridors and rooms as a graph and find the fastest route between any two rooms.
Physics + Programming
Simulate projectile motion with air drag in Python
Plot real trajectories with air resistance and compare them with the textbook parabola.
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.
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.
Programming · Scratch
Make an interactive story game in Scratch
Create a choose-your-own-adventure story with characters, scenes and choices.