A small library for pi related functions
Project description
Welcome to PiWorld! (current version 0.2.0)
PiWorld is a small Python library (mainly intended as a personal project) which houses a couple pi-related commands.
Here, pi is stored as a string as an alternative to floating-point limits (where pi's value is only accurate up to the 15th decimal).
Current Commands
The library currently has 8 commands:
pi10→ returns pi up to the 10th decimalpi20→ returns pi up to the 20th decimalpi50→ returns pi up to the 50th decimalpi100→ returns pi up to the 100th decimalpi200→ returns pi up to the 200th decimalpi500→ returns pi up to the 500th decimalpidigit(n)→ returns the nth decimal of pi (if n == 0, the functions returns 3, for the digit before the decimals)pislice(length, size)→ slices pi into a "length" sized string, then divides it into chunks with "size" characters
(More coming soon)
Example Usage
The embedded constants can be used as follows:
import piworld
print(piworld.pi10) # Output: 3.1415926535
print(piworld.pi20) # Output: 3.14159265358979323846
print(piworld.pi50) # Output: 3.14159265358979323846264338327950288419716939937510
print(piworld.pi100) # Output: 3.1415926535.....21170679
print(piworld.pi200) # Output: 3.1415926535.....93038196
print(piworld.pi500) # Output: 3.1415926535.....01194912
In addition to that, the two remaining functions work like so:
from piworld import pidigit, pislice
"""pidigit(n) returns the nth digit of pi, unless n is 0,
which returns 3 for the digit before the decimals instead"""
print(pidigit(0)) # returns 3
print(pidigit(1)) # returns 1
print(pidigit(2)) # returns 4
print(pidigit(3)) # returns 1
print(pidigit(4)) # returns 5
"""pislice(length, size) returns the decimals of pi up to the set 'length',
then chunks it into slices containing 'size' characters each
notice how when 'size' isn't divisible by 'length', the remaining digits are set at the end"""
print(pislice(10, 2)) # returns 14 14 92 65 35
print(pislice(15, 3)) # returns 141 592 653 589 793
print(pislice(18, 4)) # returns 1415 9265 3589 7932 38
print(pislice(23, 5)) # returns 14159 26535 89793 23846 264
PiWorld GitHub Repository
Yo can find the GitHub repository for PiWorld over at https://github.com/seif-kz/piworld
PLEASE NOTE
This is not meant to be a fully practical library with groundbreaking use —
it is simply a fun little project serving as my own introduction to PyPI and GitHub.
This project might be getting some sparse updates here and there, but nothing major.
Contact
TBA
~ Seif
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 piworld-0.2.0.tar.gz.
File metadata
- Download URL: piworld-0.2.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56dc8fdb28105f95e38f843001928ecede306dc9e91af8ae839c18086f655c73
|
|
| MD5 |
8aa3b8737b428a1b2fe1773f2e1117bd
|
|
| BLAKE2b-256 |
e4b3c2a57b52911734b6ddb1c655f2b3ae2a77d677072256dd3b5f8827d63c96
|
File details
Details for the file piworld-0.2.0-py3-none-any.whl.
File metadata
- Download URL: piworld-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1327e5f2c1a99942e9b84321c3a142ebacd1fbf7134eef48b0d6d24040bfc440
|
|
| MD5 |
5f3151f3103c66f8ebe6f99729620f8e
|
|
| BLAKE2b-256 |
1cd9c74a667ec2464f20e1f88749946d3f1d522dba42e36c6fd98d4371a83686
|