Introduction to Functions in Python
Learn the art of writing your own functions in Python, as well as key concepts like scoping and error handling.
Commencer Le Cours Gratuitement3 heures10 vidéos44 exercices428 824 apprenantsDéclaration de réalisation
Créez votre compte gratuit
ou
En continuant, vous acceptez nos Conditions d'utilisation, notre Politique de confidentialité et le fait que vos données sont stockées aux États-Unis.Formation de 2 personnes ou plus ?
Essayer DataCamp for BusinessApprécié par les apprenants de milliers d'entreprises
Description du cours
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.
Formation de 2 personnes ou plus ?
Donnez à votre équipe l’accès à la plateforme DataCamp complète, y compris toutes les fonctionnalités.Dans les titres suivants
- 1
Writing your own functions
GratuitYou'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 xpStrings in Python50 xpRecapping built-in functions50 xpWrite a simple function100 xpSingle-parameter functions100 xpFunctions that return single values100 xpMultiple parameters and return values50 xpFunctions with multiple parameters100 xpA brief introduction to tuples100 xpFunctions that return multiple values100 xpBringing it all together50 xpBringing it all together (1)100 xpBringing 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.
Scope and user-defined functions50 xpPop quiz on understanding scope50 xpThe keyword global100 xpPython's built-in scope50 xpNested functions50 xpNested Functions I100 xpNested Functions II100 xpThe keyword nonlocal and nested functions100 xpDefault and flexible arguments50 xpFunctions with one default argument100 xpFunctions with multiple default arguments100 xpFunctions with variable-length arguments (*args)100 xpFunctions with variable-length keyword arguments (**kwargs)100 xpBringing it all together50 xpBringing it all together (1)100 xpBringing it all together (2)100 xp - 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.
Lambda functions50 xpPop quiz on lambda functions50 xpWriting a lambda function you already know100 xpMap() and lambda functions100 xpFilter() and lambda functions100 xpReduce() and lambda functions100 xpIntroduction to error handling50 xpPop quiz about errors50 xpError handling with try-except100 xpError handling by raising an error100 xpBringing it all together50 xpBringing it all together (1)100 xpBringing it all together (2)100 xpBringing it all together (3)100 xpBringing it all together: testing your error handling skills50 xp
Formation de 2 personnes ou plus ?
Donnez à votre équipe l’accès à la plateforme DataCamp complète, y compris toutes les fonctionnalités.Dans les titres suivants
Hugo Bowne-Anderson
Voir PlusData Scientist
Qu’est-ce que les autres apprenants ont à dire ?
Inscrivez-vous 15 millions d’apprenants et commencer Introduction to Functions in Python Aujourd’hui!
Créez votre compte gratuit
ou
En continuant, vous acceptez nos Conditions d'utilisation, notre Politique de confidentialité et le fait que vos données sont stockées aux États-Unis.