Skip to main content

A simple package to implement a Magic 8Ball.

Project description

TheGrotShop logo
Github Build Status License Created
Release Released Commits since release

Overview

Overview

Magic 8-Ball is a Python package that emulates the classic Magic 8-Ball toy, providing randomized responses to yes-or-no questions. This package is designed to be both interactive and usable in various applications, allowing developers to integrate a fun, nostalgic feature into their projects.

Features

  • 20 traditional Magic 8-Ball responses (positive, neutral, and negative).
  • Simple API to ask questions and get a response.
  • Custom error handling for invalid inputs.
  • Includes comprehensive test coverage.

Installation

pip install wolfsoftware.magic8ball

Usage

Basic Example

Once installed, you can use the Magic 8-Ball package in your Python code.

from wolfsoftware.magic8ball import Magic8Ball

# Create an instance of Magic8Ball
magic_ball = Magic8Ball()

# Ask a yes/no question
response = magic_ball.ask_question("Will it rain tomorrow?")
print("Magic 8-Ball says:", response)

Handling Errors

The ask_question method raises an InvalidQuestionError if the question provided is not a non-empty string. Make sure to validate the input or handle this exception as shown:

from wolfsoftware.magic8ball import Magic8Ball, InvalidQuestionError

magic_ball = Magic8Ball()

try:
    response = magic_ball.ask_question("Will I get a promotion?")
    print("Magic 8-Ball says:", response)
except InvalidQuestionError as e:
    print("Error:", e)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wolfsoftware_magic8ball-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

wolfsoftware.magic8ball-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file wolfsoftware_magic8ball-0.1.0.tar.gz.

File metadata

File hashes

Hashes for wolfsoftware_magic8ball-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb899c2815c857d1915d5d88374ebfd884b5a0e135362f75114ace9a5384bd37
MD5 9dc69f40dfc492317f31b69eb2228f09
BLAKE2b-256 e5adf0696a385d067a925e525e34ae72b9b97540a7d88972b1673a8db703f598

See more details on using hashes here.

File details

Details for the file wolfsoftware.magic8ball-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wolfsoftware.magic8ball-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc94beac4fffd8a66eab0777731cc4933a06ed6b3530715a361614afa7b2a8b5
MD5 438390e11a09b4438f18ed9b2746fca0
BLAKE2b-256 370a7b890ed078c6f516bbb3892e2bce7e3efee658a03cd945007ccc4dd3f39d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page