More about functions when using Python for data scince

ssuser4ab9671 7 views 10 slides Apr 25, 2024
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

In Python, functions are an


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.
Tags