Giter Club home page Giter Club logo

backend-numseq-package-assessment's Introduction

Overview - Creating Packages

In this assignment you will use TDD methodolgy to create several modules for computing various mathematical sequences. The modules will then be grouped into a hierarchical package structure, with a top-level package name of numseq. You will write tests first, then write code to pass the tests.

numseq

Create a package folder named numseq, with the structure shown below.

Packages allow us organize and group modules (or python files). Python requires a specific structure for package definitions. The directory name is the name of the package used in an import statement (import package_name). The submodules can be access as attributes of the package as in package_name.submodule_name.

├── numseq
│   ├── __init__.py
│   ├── fib.py
│   ├── geo.py
│   ├── prime.py

__init__.py

The __init__.py files are required to make Python treat directories containing the file as packages. This prevents directories with a common name, such as string, unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.

-- python docs

fib

Within the numseq package, create a module named fib.py. Within the fib module, define a function fib(n) that returns the nth Fibonacci number. The first 10 terms of the Fibonacci sequence are [0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ...]

geo

Within the numseq package, create a module named geo.py. Within this geo module, define 3 functions:

  • square(n) : Returns the nth term of the numbers that can be arranged into square geometric shapes [1, 4, 9, 16, 25 ... ]

  • triangle(n) : Returns the nth term of the numbers that can be arranged in triangular geometric shapes [1, 3, 6, 10, 15, 21, 28, 36, 45, 55 ... ]

  • cube(n) : Returns the nth term of the numbers that can be arranged as symmetric cube shapes [1, 8, 27, 64 ...]

prime

Finally, create a module named prime.py within the numseq package. Define the following functions:

  • primes(n): Returns a list of all prime numbers less than n
  • is_prime(m) : Returns a boolean indicating whether m is a prime number

Testing

  • Use the VSCode built-in test discovery feature to run and debug individual tests
  • discover and run all tests

$ python -m unittest discover

  • run only one test

$ python -m unittest test_numseq.TestNumseq.test_prime

PR (Pull Request) Workflow for this Assignment

  1. Fork this repository into your own personal github account.
  2. Then Clone your own repo to your local development machine.
  3. Create a separate branch named dev, and checkout the branch.
  4. Commit your changes, then git push the branch back to your own github account.
  5. From your own Github repo, create a pull request (PR) from your dev branch back to your own master.
  6. Copy/Paste the URL link to your PR as your assignment submission.
  7. Your grader will post code review comments inline with your code, in your github account. Be sure to respond to any comments and make requested changes. RESUBMIT a new link to your PR after making changes. This is the code review iteration cycle.

backend-numseq-package-assessment's People

Contributors

madarp avatar mikaiyl-davis avatar

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.