Skip to main content

A simple, elegant Python framework for creating and running interactive quizzes

Project description

Quizy ๐ŸŽฏ

A simple, elegant Python framework for creating and running interactive quizzes

Python Version License

Quizy makes it incredibly easy to create educational quizzes, assessments, and interactive learning experiences in Python. Whether you're a teacher, student, or developer, Quizy provides a clean API for building engaging quiz applications.

โœจ Features

  • ๐Ÿš€ Simple API - Create quizzes in just a few lines of code
  • ๐Ÿ“ Interactive CLI - Built-in command-line interface for running quizzes
  • ๐ŸŽจ Customizable - Add explanations, customize questions, and build complex quizzes
  • ๐Ÿ”Œ Extensible - Easy to integrate into your own applications
  • ๐Ÿ“ฆ Zero Dependencies - Pure Python, no external packages required
  • โœ… Type-Safe - Clean, well-documented code with proper error handling

๐Ÿš€ Quick Start

Installation

pip install quizy

Or install from source:

git clone https://github.com/yourusername/quizy.git
cd quizy
pip install -e .

Your First Quiz in 30 Seconds

import quizy as q

# Use a built-in quiz
quiz_101 = q.quiz_101
quiz_101.start()

That's it! You'll get an interactive quiz experience right in your terminal.

๐Ÿ“– Usage Guide

Using Built-in Quizzes

Quizy comes with sample quizzes to get you started:

import quizy as q

# Python Basics Quiz
quiz_101 = q.quiz_101
quiz_101.start()

# Data Structures Quiz
quiz_102 = q.quiz_102
quiz_102.start()

Creating Custom Quizzes

Build your own quizzes with the Quiz and Question classes:

from quizy import Quiz, Question

# Create a new quiz
geography_quiz = Quiz("World Geography Challenge")

# Add questions with multiple choice options
geography_quiz.add_question(Question(
    text="What is the capital of France?",
    options=["London", "Berlin", "Paris", "Madrid"],
    correct_answer="Paris",
    explanation="Paris has been the capital of France since the 12th century"
))

geography_quiz.add_question(Question(
    text="Which is the largest ocean?",
    options=["Atlantic", "Indian", "Arctic", "Pacific"],
    correct_answer="Pacific",
    explanation="The Pacific Ocean covers about 63 million square miles"
))

# Start the quiz
geography_quiz.start()

Advanced Example: Programming Quiz

from quizy import Quiz, Question

# Create a coding quiz
coding_quiz = Quiz("Python Programming Quiz")

# Add technical questions
coding_quiz.add_question(Question(
    text="What is the time complexity of list.append() in Python?",
    options=["O(1)", "O(log n)", "O(n)", "O(nยฒ)"],
    correct_answer="O(1)",
    explanation="List append is amortized O(1) due to dynamic array implementation"
))

coding_quiz.add_question(Question(
    text="Which keyword is used to create a generator in Python?",
    options=["return", "yield", "generate", "async"],
    correct_answer="yield",
    explanation="The yield keyword creates a generator that can pause and resume execution"
))

coding_quiz.add_question(Question(
    text="What does the __init__ method do in Python classes?",
    options=[
        "Deletes an object",
        "Initializes a new instance",
        "Imports a module",
        "Defines a static method"
    ],
    correct_answer="Initializes a new instance",
    explanation="__init__ is the constructor method called when creating new class instances"
))

# Run the quiz
coding_quiz.start()

Working with Quiz Data Programmatically

from quizy import Quiz, Question

# Create a quiz
my_quiz = Quiz("Math Quiz")
my_quiz.add_question(Question(
    text="What is 12 ร— 15?",
    options=["150", "180", "200", "175"],
    correct_answer="180"
))

# Inspect quiz contents
print(f"Title: {my_quiz.title}")
print(f"Questions: {len(my_quiz.get_questions())}")

# Iterate through questions
for i, question in enumerate(my_quiz.get_questions(), 1):
    print(f"{i}. {question.text}")
    print(f"   Answer: {question.correct_answer}")

CLI Usage

After installation, run quizzes directly from your terminal:

quizy

This launches an interactive menu where you can select from available quizzes.

๐Ÿ“š API Reference

Question

Creates a single quiz question with multiple choice answers.

Question(text, options, correct_answer, explanation=None)

Parameters:

  • text (str): The question text
  • options (list): List of possible answers (strings)
  • correct_answer (str): The correct answer (must be in options)
  • explanation (str, optional): Explanation shown after answering

Methods:

  • check_answer(user_answer) - Returns True if the answer is correct

Example:

q = Question(
    text="What is 2 + 2?",
    options=["3", "4", "5", "6"],
    correct_answer="4",
    explanation="Basic arithmetic: 2 plus 2 equals 4"
)

Quiz

Creates a quiz containing multiple questions.

Quiz(title, questions=None)

Parameters:

  • title (str): Quiz title displayed to users
  • questions (list, optional): Initial list of Question objects

Methods:

  • add_question(question) - Add a Question to the quiz
  • start() - Launch interactive quiz session
  • get_questions() - Return list of all questions
  • clear() - Remove all questions and reset score

Attributes:

  • title - Quiz title
  • questions - List of Question objects
  • score - Current score (after running quiz)
  • total - Total number of questions

Example:

quiz = Quiz("Science Quiz")
quiz.add_question(Question(...))
quiz.add_question(Question(...))
quiz.start()  # Runs interactively

print(f"Final Score: {quiz.score}/{quiz.total}")

๐Ÿ—๏ธ Project Structure

quizy/
โ”œโ”€โ”€ pyproject.toml       # Package configuration
โ”œโ”€โ”€ README.md            # This file
โ”œโ”€โ”€ LICENSE              # MIT License
โ””โ”€โ”€ quizy/
    โ”œโ”€โ”€ __init__.py      # Package exports
    โ”œโ”€โ”€ core.py          # Quiz and Question classes
    โ”œโ”€โ”€ quiz_101.py      # Sample: Python Basics
    โ”œโ”€โ”€ quiz_102.py      # Sample: Data Structures
    โ””โ”€โ”€ main.py          # CLI entry point

๐Ÿ› ๏ธ Development

Local Development Setup

# Clone the repository
git clone https://github.com/yourusername/quizy.git
cd quizy

# Install in editable mode
pip install -e .

# Test your changes
python -c "import quizy; print(quizy.__version__)"

Building the Package

# Install build tools
pip install build

# Build distribution packages
python -m build

# Output: dist/quizy-0.1.0.tar.gz and dist/quizy-0.1.0-py3-none-any.whl

Publishing to PyPI

# Install twine
pip install twine

# Upload to PyPI (requires PyPI account)
twine upload dist/*

# Or upload to TestPyPI first
twine upload --repository testpypi dist/*

๐ŸŽ“ Use Cases

  • Education: Create interactive learning materials for students
  • Training: Build corporate training quizzes and assessments
  • Interviews: Develop technical screening questions
  • Self-Study: Create personal study aids for exam preparation
  • Gamification: Add quiz elements to your applications

๐Ÿค Contributing

Contributions are welcome! Here are some ways you can help:

  • ๐Ÿ› Report bugs and issues
  • ๐Ÿ’ก Suggest new features
  • ๐Ÿ“ Improve documentation
  • ๐Ÿ”ง Submit pull requests

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

Built with โค๏ธ for educators, students, and developers who believe in the power of interactive learning.


Happy Quizzing! ๐ŸŽ‰

For questions, issues, or suggestions, please visit GitHub Issues.

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

quizy-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

quizy-0.1.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file quizy-0.1.1.tar.gz.

File metadata

  • Download URL: quizy-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for quizy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 543995386b4b1054e8e528cec3a11588b6ca1f4f0833ead7bbc086a3798a9328
MD5 eab318ceeeb5ea2574cee6085e8ab673
BLAKE2b-256 8c250a775e1e25ddc3455983b1216282e33a62a939af942d2cb6ea889370c9e0

See more details on using hashes here.

File details

Details for the file quizy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: quizy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for quizy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 280aa82460eecc1ed1229c1e6b74ceebf23e0f042bba6386596aa46237bfa7ab
MD5 531e5eb6158efccc18d7032036ac263d
BLAKE2b-256 9eb5a12661603d4afc3eab821246b86451a40915a5c7a0d114881b895b647f34

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