A simple coin flip random number generator
Project description
mitchallen.coin
A simple, lightweight Python package that provides a random number generator perfect for simulations, games, and probabilistic applications.
Installation
pip install mitchallen-coin
Or using uv:
uv add 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mitchallen_coin-1.0.4.tar.gz.
File metadata
- Download URL: mitchallen_coin-1.0.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aea948e49d5baa3de8f39cabb51f39503e3f3dc33a189b697aa044b6ec43273a
|
|
| MD5 |
f7c1c1745beec11b2c570aee92567503
|
|
| BLAKE2b-256 |
c908e1f9d22dbb2bfb8ba2bc2e2e8acf486d796d9e73cf15f7cb2b1ada7ae147
|
Provenance
The following attestation bundles were made for mitchallen_coin-1.0.4.tar.gz:
Publisher:
publish.yml on mitchallen/python-coin-flip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mitchallen_coin-1.0.4.tar.gz -
Subject digest:
aea948e49d5baa3de8f39cabb51f39503e3f3dc33a189b697aa044b6ec43273a - Sigstore transparency entry: 707651053
- Sigstore integration time:
-
Permalink:
mitchallen/python-coin-flip@ab12d1c0df774db6462e2ce9b0fa928dd22bf46a -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/mitchallen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab12d1c0df774db6462e2ce9b0fa928dd22bf46a -
Trigger Event:
release
-
Statement type:
File details
Details for the file mitchallen_coin-1.0.4-py3-none-any.whl.
File metadata
- Download URL: mitchallen_coin-1.0.4-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b36fc9c2b5031f3979109767290f829407a797a213879f5922af1b4e3edf20f
|
|
| MD5 |
9b016a1f0e66a99ff29b07ed21f2b35a
|
|
| BLAKE2b-256 |
be4a258deafe95686d0694f42666910a70fa869f9966167028e3cf4904e6b742
|
Provenance
The following attestation bundles were made for mitchallen_coin-1.0.4-py3-none-any.whl:
Publisher:
publish.yml on mitchallen/python-coin-flip
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mitchallen_coin-1.0.4-py3-none-any.whl -
Subject digest:
1b36fc9c2b5031f3979109767290f829407a797a213879f5922af1b4e3edf20f - Sigstore transparency entry: 707651057
- Sigstore integration time:
-
Permalink:
mitchallen/python-coin-flip@ab12d1c0df774db6462e2ce9b0fa928dd22bf46a -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/mitchallen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab12d1c0df774db6462e2ce9b0fa928dd22bf46a -
Trigger Event:
release
-
Statement type: