More about functions when using Python for data scince
ssuser4ab9671
7 views
10 slides
Apr 25, 2024
Slide 1 of 10
1
2
3
4
5
6
7
8
9
10
About This Presentation
In Python, functions are an
Size: 108.66 KB
Language: en
Added: Apr 25, 2024
Slides: 10 pages
Slide Content
More about Python functions Xing Fang
Arguments Numbers, strings, tuples are pass by value. Lists and dictionaries are pass by reference (pointer).
Pass by value
Pass by reference
Pass by value and by reference
Default arguments A default parameter (argument) is the one that has a value assigned to it when the function is defined. The value is referred to as the default value.
Default arguments To define a function that takes both default and non-default arguments, make sure to define the default ones after the non-default ones.
Python function calls Passing arguments by their positions Passing arguments by key words
The return statement Since Python functions do not have return types, the return statement is optional. Python functions can return multiple values as a tuple:
The return statement It requires us to use the same amount of variables to hold the returned values.