50% off DataCamp Premium. 700+ courses, half price. Start learning today.
Course Description
It's time to push forward and develop your Python chops even further. Python has tons of fantastic functions and a module ecosystem. However, as a data professional or developer, you'll constantly need to write your own functions to solve problems that are dictated by your data. You will learn the art of function writing in this first course. You'll come out of this course being able to write your very own custom functions, complete with multiple parameters and multiple return values, along with default arguments and variable-length arguments. You'll gain insight into scoping in Python, be able to write lambda functions and handle errors in your function writing practice. You'll wrap up each chapter by using your new skills to write functions that analyze Twitter data.The videos contain live transcripts you can reveal by clicking "Show transcript" at the bottom left of the videos.
The course glossary can be found on the right in the resources section.
To obtain CPE credits you need to complete the course and reach a score of 70% on the qualified assessment. You can navigate to the assessment by clicking on the CPE credits callout on the right.
Feels like what you want to learn?
Start Course for FreeWhat you'll learn
- Assess error conditions in user-defined functions and apply try-except blocks or raise statements to handle exceptions effectively
- Distinguish between local, enclosing, global, and built-in scopes when accessing or modifying variables inside functions
- Evaluate the appropriate use of lambda expressions and higher-order functions such as map for concise data operations
- Identify the correct syntax for defining Python functions that accept single or multiple parameters and return single or multiple values
- Recognize how to implement default arguments, *args, and **kwargs to create flexible function interfaces
Prerequisites
Curriculum
Course outline
1
Writing your own functions
You'll learn how to write simple functions, as well as functions that accept multiple arguments and return multiple values. You'll also have the opportunity to apply these new skills to questions commonly encountered by data professionals and developers.
- User-defined functions50 XP
- Strings in Python50 XP
- Recapping built-in functions50 XP
- Write a simple function100 XP
- Single-parameter functions100 XP
- Functions that return single values100 XP
- Multiple parameters and return values50 XP
- Functions with multiple parameters100 XP
- A brief introduction to tuples100 XP
- Functions that return multiple values100 XP
- Bringing it all together50 XP
- Bringing it all together (1)100 XP
- Bringing it all together (2)100 XP
2
Default arguments, variable-length arguments and scope
You'll learn to write functions with default arguments so that the user doesn't always need to specify them, and variable-length arguments so they can pass an arbitrary number of arguments on to your functions. You'll also learn about the essential concept of scope.
3
Lambda functions and error-handling
Learn about lambda functions, which allow you to write functions quickly and on the fly. You'll also practice handling errors in your functions, which is an essential skill. Then, apply your new skills to answer data science questions.
Introduction to Functions in Python
Course
Complete

