September 2026
1051 pages
35h 4m
English
At the beginning of this chapter, we introduced the concept of functions in Python using the built-in range function. You’ll certainly remember from Chapter 5, Section 5.2.5 about the for loop that the last of the three parameters of the range function is optional, which means that it can be omitted when you call the function. An optional parameter must be preassigned with a value internally in the function, usually a default value, which is sufficient in most function calls. In the range function, the third parameter controls the step size and is preset to 1. The following calls of range are therefore equivalent:
range(2, 10, 1)range(2, 10)
This is interesting because a function often has a default behavior, which ...
Read now
Unlock full access