Ratings & reviews

4.112 ratings

Marcello S.

11 days ago

Need to understand practical examples where functions changes our daily lives, not only coding snippets.

Tien N.

12 days ago

This lesson was a little bit harder to understand. I wish there was a little more explanation in the solutions.

Kjell W.

13 days ago

Good explaining… Step by step learning to code

42%
25%
33%
0%
0%
info

Complete all chapters to get certificate

0%

What is Function in Python?

chevron

Now we will consider what a function in Python and some basic techniques used to create functions is: what are the arguments of the function, what is the return value of the function, what is the body of the function, and how to use the function in the code.

What Is Function?

Arguments

Return Value

Function Body

Built-in Functions

Function Argument Specification

chevron

Python is a fairly flexible language in terms of creating functions. This is especially true in setting function arguments - there are several different types of function arguments, and you can choose any of them depending on the problem you are solving. Let's now take a closer look at them.

Positional Arguments. Optional Arguments

Challenge: Optional Arguments

Arbitrary Arguments

Combination of Positional, Arbitrary and Optional Arguments

Arbitrary Keyword Arguments

Using Combinations of All Argument Types

Function Return Value Specification

chevron

The return value of a function is the direct result of the execution of the function, which we can use in the program. There are several types of function return values - now we will consider the most commonly used.

Single Return Value

Multiple Return Values

None Return Value

Generator Functions

Some Additional Topics

chevron

Now it's time to consider additional topics to help make your functions more flexible and solve more complicated tasks. You will understand recursion, lambda functions, and some basics principles of writing effective and maintainable functions.

Recursion

Lambda Functions

Writing Effective and Maintainable Functions