Python Functions: Built-in Functions and Multiple Return Statements
In this lesson, you’ll expand what you learned about functions in previous lessons to write better code while avoiding common pitfalls. You’ll also learn more functions concepts, such as interfering with built-in functions, function default arguments, consulting the official Python documentation, and using multiple return statements with functions.
You’ll learn how to use documentation by 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’ll be learning constantly and exploring unfamiliar territory when writing code.
In the Variables, Data Types, and Lists in Python course, we used commands such as
round(). In the Python Functions: Using Built-in Functions and Creating Functions lesson, you built new functions.
When writing a program, you could just keep rewriting the same code, but that would be tedious, and it would 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 can use the function anytime to save time and resources. A function displays these patterns: it takes an input, transforms the input, and returns an output.
As you go through this lesson, you’ll have the 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.
- Learn how to troubleshoot interactions with built-in functions
- Learn how to define default function arguments
- Learn how to use official Python documentation
- Learn how to employ multiple return statements
- Interfering with the Built-in Functions
- Variable Names and Built-in Functions
- Default Arguments
- The Official Python Documentation
- Multiple Return Statements
- Not Using the else Clause