Giter VIP home page Giter VIP logo

a007's Introduction

0x07. Python - Test-driven development

I learned about docstring and unittest in Python.

Tests โœ”๏ธ

Function Prototypes ๐Ÿ’พ

Prototypes for functions written in this project:

File Prototype
0-add_integer.py def add_integer(a, b=98):
2-matrix_divided.py def matrix_divided(matrix, div):
3-say_my_name.py def say_my_name(first_name, last_name=""):
4-print_square.py def print_square(size):
5-text_indentation.py def text_indentation(text):
100-matrix_mul.py def matrix_mul(m_a, m_b):
101-lazy_matrix_mul.py def lazy_matrix_mul(m_a, m_b):
102-python.c void print_python_string(PyObject *p);

Tasks ๐Ÿ“ƒ

  • 0. Integers addition

    • 0-add_integer.py: Python function that returns the integer addition of two numbers.
    • If either of a or b is not an int or float, a TypeError is raised with the message a must be an integer or b must be an integer.
    • If either of a or b is a float, it is casted to an int before addition.
  • 1. Divide a matrix

    • 2-matrix_divided.py: Python function that divides all elements of a matrix by a common divisor.
    • Returns a new matrix representing the division of all elements of matrix by div.
    • Quotients are rounded to two decimal places.
    • If matrix is not a list of lists of ints or floats, a TypeError is raised with the message matrix must be a matrix (list of lists) of integers/floats.
    • If matrix contains rows of different lengths, a TypeError is raised with the message Each row of the matrix must have the same size.
    • If the divisor div is not an int or float, a TypeError is raised with the message div must be a number.
    • If div is 0, a ZeroDivisionError is raised with the message division by zero.
  • 2. Say my name

    • 3-say_my_name.py: Python function that prints a name in the format My name is <first_name> <last_name>.
    • If either of first_name or last_name is not a str, a TypeError is raised with the message first_name must be a string or last_name must be a string.
  • 3. Print square

    • 4-print_square.py: Python function that prints a square using the # character.
    • The paramter size represents the height/width of the square.
    • If size is not an int, a TypeError is raised with the message, size must be an integer.
    • If size is less than 0, a ValueError is raised with the message size must be >= 0.
  • 4. Text indentation

    • 5-text_indentation.py: Python function that prints text with indentation.
    • Two new lines are printed after any ., ?, or : character.
    • If text is not a str, a TypeError is raised with the message text must be a string.
    • No spaces are printed at the beginning or end of each printed line.
  • 5. Max integer - Unittest

    • tests/6-max_integer_test.py: Python class/script that runs unittests for the function def max_integer(list=[]): (provided by Holberton School).
  • 6. Matrix multiplication

    • 100-matrix_mul.py: Python function that multiplies two matrices.
    • Returns a new matrix representing the multiplication of m_a by m_b.
    • If either of m_a or m_b is empty (ie. == [] or == [[]]), a ValueError is raised with the message m_a can't be empty or m_b can't be empty.
    • If either of m_a or m_b is not a list, a TypeError is raised with the message m_a must be a list or m_b must be a list.
    • If either of m_a or m_b is not a list of lists, a TypeError is raised with the message m_a must be a list of lists or m_b must be a list of lists.
    • If either of m_a or m_b is not a list of lists of ints or floats, a TypeError is raised with the message m_a should contain only integers or floats or m_b should contain only integers or floats.
    • If either of m_a or m_b contains rows of different lengths, a TypeError is raised with the message each row of m_a must should be of the same size or each row of m_b must should be of the same size.
    • If m_a and m_b cannot be multiplied (ie. row size of m_a does not match column size of m_b), a ValueError is raised with the message m_a and m_b can't be multiplied.
  • 7. Lazy matrix multiplication

  • 8. CPython #3: Python Strings

    • 102-python.c: C function that prints basic information about Python string objects.

a007's People

Contributors

flovian 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.