Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Optional Arguments | Function Arguments in Details
Mastering Python: Annotations, Errors and Environment
course content

Contenido del Curso

Mastering Python: Annotations, Errors and Environment

Mastering Python: Annotations, Errors and Environment

1. Annotations
2. Function Arguments in Details
3. Error Handling
4. Virtual Environment

Optional Arguments

The positional arguments are required to be filled in. However, you can assign a default value to the positional argument using the = operator:

In the example above, if you don't pass a value to the name argument, it will be assigned the default value "UnknownName". The default value "UnknownSurname" and the surname argument work similarly.

The default value makes the corresponding positional arguments optional, but the total number of positional arguments required to be passed remains strict.

In the next chapter, we will describe how to define a function that can take a variable number of arguments.

How many arguments the add() function requires to take?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 2. Capítulo 2
We're sorry to hear that something went wrong. What happened?
some-alt