Skip to main content

Module for generating and printing Pascal's Triangle

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pascal-tri-1.2.6.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

pascal_tri-1.2.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pascal-tri-1.2.6.tar.gz.

File metadata

  • Download URL: pascal-tri-1.2.6.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pascal-tri-1.2.6.tar.gz
Algorithm Hash digest
SHA256 1a40f5b95b90f5bc4fe5ec8dff4e26b07b752eadeefbdb7d2bbfb1aba02379f6
MD5 b9d71276300d78be255d170c3ff549d1
BLAKE2b-256 a0164f6d37cfdd51e8093c2dfa50a0810b827edbbabec11116d4a4e6c47f1171

See more details on using hashes here.

Provenance

File details

Details for the file pascal_tri-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: pascal_tri-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pascal_tri-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c36b55faf1f55030a510ffbc2002e0015b0964ba466db5ed1cbd80b2b8b515f3
MD5 f1e5eb9c41d4135cc32b062ec358002b
BLAKE2b-256 992d5e34ffa576b577a759d1bac9741fe01c4a057a3f0136f16131cdba6bb45f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page