https://github.com/jack-mil/pascal-tri
Python 3 Package to generate Pascal's Triangle
https://github.com/jack-mil/pascal-tri
pascal-triangle-generator pypi-package python3
Last synced: about 2 months ago
JSON representation
Python 3 Package to generate Pascal's Triangle
- Host: GitHub
- URL: https://github.com/jack-mil/pascal-tri
- Owner: jack-mil
- License: mit
- Created: 2020-03-15T14:13:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-10T02:35:01.000Z (almost 4 years ago)
- Last Synced: 2025-03-19T03:11:10.149Z (2 months ago)
- Topics: pascal-triangle-generator, pypi-package, python3
- Language: Python
- Homepage: https://pypi.org/project/pascal-tri/
- Size: 44.9 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pascal-Triangle
## Module for generating and printing Pascal's Triangle ##
### Requires *Python 3.9* (type hints) ###Explicit implementation of Pascal's Triangle algorithm. Each row can be generated separately from all others. This vastly speeds up time if all you need is row 100 for example.
This module is intended to be useful for mathematics or anytime a row(s) of Pascal's triangle might be useful.### Installation ###
*Pascal-triangle* can be installed directly with pip to use as a library and shell command by running `pip install pascal-tri`OR clone the repo and run `python -m pascal`
### Includes methods for ###
> * generating a list of triangle rows
> * pretty printing a triangle with correct spacing and alignmentThe pascal module defines the following methods, access with
```py
from pascal import *
```
```py
# To generate a explicit row 'n' of Pascal's triangle:
calculate_row(n: int) -> PascalRow# To generate a list of 'n' rows:
pascal(n: int) -> PascalTriangle# Pretty print to stdout a triangle with 'n' rows or (optionally) a supplied triangle:
print_pascal(n: int, triangle: PascalTriangle = None) -> None
```
Can be run as a script as well.python -m pascal [-h] [-l LINES]
If LINES not specified, runs in interactive loop## Learning objectives ##
This project exists as an exercise in learning these techonlogies/concepts
- Python type hinting (VS code intellisense integration)
- Making distributable Python packages (PyPi)
- Github Actions to build/publish automatically