Summary

In this chapter, we learned one of the main pillars of code – functions. Functions allow us to write concise and expressive code that can be reused multiple times. Functions serve as building blocks of our programs – be it report generation, interaction with the APIs, or training the model. We discussed how to declare both standard and anonymous functions, how to set arguments, and their default values, and how to use args and kwargs for more flexible interface design. We also learned how to write good quality documentation strings and add type annotations. Finally, we did rewrite our code from the previous chapter, using functions, which made it slightly more expressive and error-prone.

In the last section, we defined recursion – an approach where a function is called from within itself, and which allows us to solve rather complex tasks with simple, chained snippets of code.

In the next chapter, we will talk about data structures. Data structures are the way in which the program can compose many data values into collections. There are quite a few different ways to structure your data – some variants are good for general-purpose cases, while others are better for specific tasks. Knowing data structures is an essential part of programming.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.61.73