Skip to content

Commit c0f1383

Browse files
authored
Update README.md
1 parent cf8547e commit c0f1383

1 file changed

Lines changed: 52 additions & 12 deletions

File tree

README.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,64 @@
1-
# 📊 Percentify
1+
# 📊 Percentify
22

3-
**Percentify** — because fractions are overrated 😎
4-
A ridiculously tiny Python library for turning *"part of a whole"* into neat percentages without the brain math.
3+
[![PyPI version](https://img.shields.io/pypi/v/percentify.svg?style=flat&color=blue)](https://pypi.org/project/percentify/)
4+
[![Python Versions](https://img.shields.io/pypi/pyversions/percentify.svg?style=flat&color=green)](https://pypi.org/project/percentify/)
5+
[![License](https://img.shields.io/pypi/l/percentify.svg?style=flat&color=orange)](LICENSE)
6+
[![Build Status](https://github.com/data-centt/percentify/actions/workflows/python-app.yml/badge.svg)](https://github.com/data-centt/percentify/actions/workflows/python-app.yml)
7+
8+
**Percentify** — a tiny Python helper that turns *"part of a whole"* into a clean percentage.
9+
Stop typing `(part / whole) * 100` and worrying about division by zero.
510

611
---
712

8-
## ✨ Features
9-
- ✅ Calculate the percentage of any two numbers
10-
- ✅ Safe divide (returns `0.0` if the denominator is zero — no more crashes 🎉)
11-
- ✅ Control the number of decimal places
12-
- ✅ Zero dependencies, ultra-lightweight
13+
## ✨ What It Does
1314

14-
---
15+
Percentify gives you a single function:
1516

16-
## 📦 Installation and Use Case
17+
- Calculates what percentage one number is of another.
18+
- Handles divide-by-zero safely (returns 0.0 instead of crashing).
19+
- Lets you choose how many decimal places to round to.
20+
- Has zero dependencies — just pure Python.
1721

18-
```bash
22+
## 📦 Installation
23+
```
1924
pip install percentify
25+
```
2026

27+
### Usage
28+
```
2129
from percentify import percent
22-
percent(15, 30) == 50%
30+
31+
# Basic usage
32+
percent(50, 200) # → 25.0
33+
34+
# Handles fractions
35+
percent(1, 3) # → 33.33
36+
37+
# Safe when dividing by zero
38+
percent(5, 0) # → 0.0
39+
40+
# Custom decimals
41+
percent(7, 9, 4) # → 77.7778
42+
```
43+
44+
### 🛠️ How It Works
45+
46+
The library is intentionally simple — just one function:
2347
```
48+
def percent(part: float, whole: float, decimals: int = 2) -> float:
49+
if whole == 0:
50+
return 0.0
51+
return round((part / whole) * 100, decimals)
52+
```
53+
That’s it. Clean, safe, and ready to use anywhere you need percentages in your code.
54+
55+
# 🤝 Contributing
56+
57+
Contributions are welcome!
58+
- If you have an idea (extra helpers, bug fixes, or better docs):
59+
- Fork this repo
60+
- Create a branch
61+
- Commit your changes
62+
- Open a pull request
2463

64+
I try to keep it tiny on purpose, so discuss big new features first.

0 commit comments

Comments
 (0)