Skip to main content

A simple coin flip random number generator

Project description

mitchallen.coin

PyPI version Python versions License Downloads

A simple, lightweight Python package that provides a random number generator perfect for simulations, games, and probabilistic applications.

Installation

pip install mitchallen-coin

Quick Start

from mitchallen.coin import flip, heads, tails

# Get a boolean coin flip result
result = flip()
print(result)  # True or False

# Alternative: using heads()
is_heads = heads()
print(is_heads)  # True or False

# Alternative: using tails()
is_tails = tails()
print(is_tails)  # True or False

Usage Examples

Simulate a Coin Flip

from mitchallen.coin import heads, tails

# Using heads()
if heads():
    print("Heads")
else:
    print("Tails")

# Or using tails()
if tails():
    print("Tails")
else:
    print("Heads")

Random 50/50 Decisions

from mitchallen.coin import flip

# Use flip() for 50/50 decisions
if flip():
    print("Event A happens")
else:
    print("Event B happens")

API Reference

flip()

Returns a random boolean value with 50% probability for True or False.

Returns:

  • bool: True or False with equal probability

Example:

from mitchallen.coin import flip

value = flip()
assert isinstance(value, bool)

# Use in conditional logic
if flip():
    print("Heads!")
else:
    print("Tails!")

heads()

Returns a random boolean value (same as flip()). Useful for simple boolean coin flip simulations.

Returns:

  • bool: True or False with equal probability

Example:

from mitchallen.coin import heads

result = heads()
if result:
    print("Heads!")
else:
    print("Tails!")

tails()

Returns the opposite boolean value of heads(). Returns True if heads() would return False, and False if heads() would return True.

Returns:

  • bool: The opposite of what heads() would return

Example:

from mitchallen.coin import tails

result = tails()
if result:
    print("Tails!")
else:
    print("Heads!")

Why mitchallen.coin?

  • Simple: Clean API with intuitive functions
  • Lightweight: No dependencies
  • Type-safe: Full type annotations with mypy type checking
  • Quality: Enforced code quality with Ruff linting and formatting
  • Tested: Comprehensive test suite ensuring quality and reliability
  • Namespace package: Works alongside other mitchallen packages

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup and guidelines.

License

MIT License - see LICENSE for details.

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

mitchallen_coin-1.0.2.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

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

mitchallen_coin-1.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file mitchallen_coin-1.0.2.tar.gz.

File metadata

  • Download URL: mitchallen_coin-1.0.2.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mitchallen_coin-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f01d3f9a5be4070771b51a6cb5f26792aa9725f1886b9bd2667c0f1a746d9b76
MD5 33e44541f2a4e540878ee89045367d64
BLAKE2b-256 a72b9866625c593fe5aeeeb8dd01c316b508243e551d9f4e162e806b09edcf1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mitchallen_coin-1.0.2.tar.gz:

Publisher: publish.yml on mitchallen/python-coin-flip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mitchallen_coin-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mitchallen_coin-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c24254bd38ad3b8148117104043d82f278d9f4804599f67def25c7e8f8a793ab
MD5 c23138dda1817485658d965269da7090
BLAKE2b-256 ff0d6a668c23b1c4d34c4a0c7641d8619bd168cad6c5420353982faa740d331d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mitchallen_coin-1.0.2-py3-none-any.whl:

Publisher: publish.yml on mitchallen/python-coin-flip

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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