reading-notes2

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

View the Project on GitHub M7madMomani2/reading-notes2

Classes and Objects

Image

  • Objects are an encapsulation of variables and functions into a single entity. Objects get their variables and functions from classes. Classes are essentially a template to create your objects.

Accessing Object Functions

  • To access a function inside of an object you use notation similar to accessing a variable

Image

Recursive Functions in Python

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.

Maintaining State

  • When dealing with recursive functions, keep in mind that each recursive call has its own execution context, so to maintain state during recursion you have to either:
  • Thread the state through each recursive call so that the current state is part of the current call’s execution context Keep the state in global scope