reading-notes2

https://m7madmomani2.github.io/reading-notes2

View the Project on GitHub M7madMomani2/reading-notes2

Testing and Modules

Image

In Tests We Trust — TDD with Python

  • TDD means Test-driven development which means the kind of development were you stick lots of step by step tests called unit tests
  • Unit tests are some pieces of code to exercise the input, the output and the behaviour of your code. You can write them anytime you want.
  • The greatest advantage about TDD is to craft the software design first
  • Your code will be more reliable: after a change you can run your tests and be in peace

Recursion

Image

What is Recursion

The process in which a function calls itself directly or indirectly

base condition in recursion

the solution to the base case is provided and the solution of the bigger problem is expressed in terms of smaller problems.

particular problem is solved using recursion

represent a problem in smaller problems, and add conditions that stop the recursion.

The difference between direct and indirect recursion

  • It is called direct when the function calls itself within it , And it is called indirect when the function calles another new functions that calls the same function again
  • The recursive program has greater space requirements than iterative program as all functions will remain in the stack until the base case is reached.
  • Recursion provides a clean and simple way to write code.