Lesson: Functions – Intermediate
In this lesson, you will improve on what you learned in the functions fundamentals lesson and learn more about functions to write better code while avoiding common pitfalls. You will also learn more function concepts, such as default arguments, scope, and more.
You will learn how to use documentation, exploring the official Python documentation to discover new tricks you can implement in your code. Becoming familiar with the documentation and knowing how to read it is important for a data scientist; you will be learning constantly and exploring unfamiliar territory when writing code.
In the Python for Data Science: Fundamentals course, several commands — such as
max() — were used. In the functions fundamentals lesson, you found out these commands are known as functions.
When writing a program, you could just keep rewriting the same code, but that would be quite tedious and result in an unnecessarily large program. Moreover, functions are self-contained routines that perform a specific task that you can incorporate into your program. After declaring the function, you are free to use the function anytime in an effort to save time and resources. A function displays these patterns: Takes an input, transforms the input, and gives back an output.
As you go through this lesson, you will be given an opportunity to practice your skills with our interactive code editor with built-in answer checking to ensure you have completely mastered each concept before moving on to the next.
1. Interfering with the Built-in Functions
2. Variable Names and Built-in Functions
3. Default Arguments
4. The Official Python Documentation
5. Multiple Return Statements
6. Returning Multiple Variables
7. More About Tuples
8. Functions — Code Running Quirks
9. Scopes — Global and Local
10. Scopes — Searching Order
11. Next Steps