A colorful, interactive command-line math quiz game built with Python. Practice arithmetic, track your high score, and compete against previous players, all from the terminal.
- Personalized sessions — asks for your name and greets you
- Difficulty levels — Easy, Medium, Hard, or a custom number range
- Operation selection — choose any combination of
+,-,*,/ - Timed sessions — tracks total time and average time per question
- Instant feedback — Correct / Wrong shown after every answer
- Score percentage — color-coded Green / Yellow / Red based on performance
- High score tracking — saves the all-time best score and player name to
high_score.txt - Full session history — every player's result is appended to
results.txt - Colored terminal output — uses ANSI escape codes for a polished UI
- Python 3.6 or higher
- No external libraries required. Uses only the Python standard library
python ProjectTutor.py-------- WELCOME --------
----- To the MATH - TUTOR -----
High Score: 90% by hamza
Enter your name: danish
Hello, danish! Let's get started.
How Many Questions Would You Like To Solve: 10
---- Select difficulty----
1. Easy (Numbers 1 to 10)
2. Medium (Numbers 10 to 50)
3. Hard (Numbers 50 to 100)
4. Custom Range
Enter your choice (1-4): 2
---- Select Operations ----
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
(Enter numbers separated by spaces, e.g. '1 2', or 'all' for all)
Your choice: 1 3
Solve: 24 + 18 = 42
Correct!
Solve: 35 * 12 = 400
Wrong! The answer was 420.
...
==============================
Thank You For Playing, danish!
You got 8 out of 10 questions right.
Percentage: 80%
Time took: 52.3 seconds
Average: 5.2 seconds/question
==============================
High Score: 90% by hamza
| Level | Number Range |
|---|---|
| Easy | 1 – 10 |
| Medium | 10 – 50 |
| Hard | 50 – 100 |
| Custom | Your choice |
Stores the all time best score in a humanreadable format:
High Score: 90% by hamza
Appends a new entry after every session:
[2026-03-05 14:30] hamza - 90% (9/10) - 48.2s
[2026-03-05 15:10] danish - 80% (8/10) - 52.3s
ProjectTutor.py # Main program
high_score.txt # Auto-generated — stores the all-time high score
results.txt # Auto-generated — stores all player session results
The program is built around a single class MathTutor with the following methods:
| Method | Description |
|---|---|
setup_game() |
Handles name input, difficulty selection |
setup_operations() |
Lets the player pick which operations to use |
play() |
Core question loop |
display_results() |
Calculates and prints final stats |
load_high_score() |
Reads high_score.txt on startup |
save_high_score() |
Writes to high_score.txt when beaten |
save_result() |
Appends the session result to results.txt |
This project is open source and free to use for learning purposes.