Skip to main content

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 alignment

The pascal module defines the following methods, access with

from pascal import *
    # 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)

Release files for pascal-tri 1.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pascal-tri 1.2.6
File Size Uploaded
pascal-tri-1.2.6.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pascal-tri 1.2.6
File Interpreter ABI Platform
pascal_tri-1.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / pascal-tri-1.2.6.tar.gz

Download URL pascal-tri-1.2.6.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1a40f5b95b90f5bc4fe5ec8dff4e26b07b752eadeefbdb7d2bbfb1aba02379f6
BLAKE2b-256 checksum
How to use checksums
a0164f6d37cfdd51e8093c2dfa50a0810b827edbbabec11116d4a4e6c47f1171
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Release files / pascal_tri-1.2.6-py3-none-any.whl

Download URL pascal_tri-1.2.6-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c36b55faf1f55030a510ffbc2002e0015b0964ba466db5ed1cbd80b2b8b515f3
BLAKE2b-256 checksum
How to use checksums
992d5e34ffa576b577a759d1bac9741fe01c4a057a3f0136f16131cdba6bb45f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.2.6 This release

2 release files

1.2.5

2 release files

1.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page