Giter Site home page Giter Site logo

jack-mil / pascal-tri Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 46 KB

Python 3 Package to generate Pascal's Triangle

Home Page: https://pypi.org/project/pascal-tri/

License: MIT License

Python 100.00%
python3 pascal-triangle-generator pypi-package

pascal-tri's Introduction

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)
  • Github Actions to build/publish automatically

pascal-tri's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ryanarkanghel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.