Skip to main content

A fun Python package that provides jokes for developers

Project description

Joke Center 🎭

A simple and extensible Python library for managing and retrieving jokes by category.


🚀 Features

  • Get random jokes by category
  • Add and delete jokes dynamically
  • Retrieve jokes across all categories
  • List available categories
  • Get multiple jokes at once
  • Built-in statistics support
  • Fully tested with pytest

📦 Installation

pip install joke-center-wszms384

🔧 Usage

import joke_center

# Get a joke
print(joke_center.get_joke("programming"))

# Add a joke
joke_center.add_joke("programming", "Debugging is like being the detective in a crime movie where you are also the murderer.")

# Get random joke
print(joke_center.get_random_joke())

# List categories
print(joke_center.list_categories())

📚 API Reference

get_joke(category="programming")

Return a random joke from the given category.

  • Returns fallback message if category does not exist or is empty

add_joke(category, joke)

Add a new joke to a category.

  • Automatically creates category if not exists
  • Strips leading/trailing whitespace
  • Returns "Joke cannot be empty!" if invalid input

delete_joke(category, joke)

Delete a joke from a category.

  • Returns "Category not found!" if category does not exist
  • Returns "Joke not found!" if joke is not in the category

list_categories()

Return a list of all categories.


get_random_joke()

Return a random joke across all categories.

  • Returns "No jokes available!" if no jokes exist

get_all_jokes(category)

Return all jokes in a category.

  • Returns empty list [] if category does not exist

get_multiple_jokes(category, n=1)

Return up to n random jokes from a category.

  • If n > available jokes → returns all jokes
  • If n = 0 → returns []
  • If category not found → returns []

get_stats()

Return statistics:

{
  "total_categories": 7,
  "total_jokes": 34
}

⚠️ Notes

  • Data is stored in-memory only (not persistent)
  • Not thread-safe for concurrent writes
  • Global state is mutable (functions modify shared data)

🧪 Testing

Run tests using:

python -m pytest

📄 License

GPL v3 License

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

joke_center_wszms384-0.4.0.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joke_center_wszms384-0.4.0-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file joke_center_wszms384-0.4.0.tar.gz.

File metadata

  • Download URL: joke_center_wszms384-0.4.0.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for joke_center_wszms384-0.4.0.tar.gz
Algorithm Hash digest
SHA256 edcc45e6048f70fb249933b09a00f3a83b27f23de4651dd6addb533bc5365200
MD5 27bf2183715e16dae0659a0d9880e0b3
BLAKE2b-256 1a953303e75e89a960ffc95df5f20e58d5cef4ee8e723e72b946fef60c23530b

See more details on using hashes here.

File details

Details for the file joke_center_wszms384-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for joke_center_wszms384-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31d91c3fb94d3db38f0271758cd696014bce6918c926a8e632e18f12d53cd301
MD5 56da2d1cfa1a630bf3f476e36198c324
BLAKE2b-256 b2592f020a54b27e6de0180140b81e4c620c3ea77988f3d5192bb02346e16f37

See more details on using hashes here.

Supported by

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