Magic 8-Ball Simulator: Data Structures and Algorithms Edition

Welcome to the Data Structures & Algorithms Edition of the Magic 8-Ball Simulator - a fun and interactive way to reinforce your Python skills while building a smart version of the classic toy.

This page contains a brief description and implementation instructions for the project.

Project Description

This project emulates a “Magic 8-Ball” toy. The user asks a yes/no question, and the program returns a random answer from a list of fortunes (positive, negative, or ambiguous).
In this edition, you will use multiple Python data structures and algorithms to manage responses, history, statistics, categories, and more.

Project Requirements

How to Run the Project

  1. Create a script (e.g. magic8_ds.py) that implements the required structures and logic.
  2. Run it using: python magic8_ds.py.
  3. When prompted “Ask the Magic 8-Ball a question (or type 'exit')”, enter a yes/no question.
  4. The program returns a random answer and updates relevant data structures.
  5. Commands you can type:
    • history - View last N question/answer pairs.
    • stats - See number of unique questions, most frequent ones, and category distribution.
    • undo - Remove last question/answer (if implemented).
    • search <your question> - Check if a question was asked before.
    • sort - View sorted list of questions or responses.
  6. Repeat interaction until you type exit.

Key Concepts Learned

Possible Extensions

Troubleshooting & Debugging

See the full Troubleshooting & Debugging guide for help.

← Back to Python Programming Page