Swipe to navigate through the chapters of this book
In this chapter, you’ll learn how to group statements into functions, which enables you to tell the computer how to do something, and to tell it only once. You won’t need to give it the same detailed instructions over and over. The chapter provides a thorough introduction to parameters and scoping, and you’ll learn what recursion is and what it can do for your programs.
Please log in to get access to this content
To get access to this content you need the following product:
Actually, functions in Python don’t always return values. You’ll learn more about this later in the chapter.
In fact, with the estimated number of particles in the observable universe at 10 87, you would need only about 290 questions to discern between them!
The name “lambda” comes from the Greek letter, which is used in mathematics to indicate an anonymous function.
Actually, instead of this lambda function, you could import the function add from the operator module, which has a function for each of the built-in operators. Using functions from the operator module is always more efficient than using your own functions.
Magnus Lie Hetland
- Sequence number
- Chapter number
- Chapter 6