A command-line trivia quiz application that fetches random questions from the Open Trivia Database API and tracks your score.
- Fetch trivia questions from Open Trivia Database API
- Choose the number of questions (1-50)
- Select difficulty level (easy, medium, hard, or random)
- Multiple choice questions with shuffled answers
- Real-time feedback on answers
- Final score with performance rating
- Clean and interactive CLI interface
- Python 3.6+
- requests library
- Install required dependencies:
pip install requestsRun the script:
python trivia_quiz.pyFollow the prompts to:
- Enter the number of questions you want (default: 10)
- Select difficulty level (or press Enter for any difficulty)
- Answer each question by entering the number corresponding to your choice
- View your final score and performance rating
============================================================
Welcome to Random Trivia Quiz CLI!
============================================================
How many questions? (1-50, default 10): 5
Difficulty levels: easy, medium, hard (or press Enter for any)
Select difficulty: medium
Fetching questions...
============================================================
Question 1
Category: Science: Computers
Difficulty: Medium
============================================================
What does CPU stand for?
1. Central Process Unit
2. Computer Personal Unit
3. Central Processing Unit
4. Central Processor Unit
Your answer (enter number): 3
✓ Correct!
...
This project uses the Open Trivia Database API to fetch trivia questions.
This project is part of the 100 Lines of Python Code repository.
Solves Issue #1099 - Random Trivia Quiz CLI