Member-only story

Understand Function in Python

Define a function, set default params, use closure.

Shuai Li
2 min readNov 29, 2021

Today I gonna learn to use functions in Python as a series of learning Python from Scratch. Before I search any tutorials, my goals are to know the following questions:

  • How to define a function?
  • Does the language support function overloading?
  • How to set default params?
  • How to write a high-order function?
  • Can I use closure?

With these questions in mind, I started googling the keywords:

python function

Here are what I learned.

How to define a function?

We can use def to define a function:

Does Python support function overloading?

No. Python is dynamically language, function overloading is not necessory.

How to set default params?

--

--

Shuai Li
Shuai Li

Written by Shuai Li

An enthusiastic game player of Earth Online.

No responses yet