Guido doesn’t like lambda functions too much.
Yet, most large code projects contain a lot of them! (Many coders use lambda functions as GUI callbacks, etc.)
In this “Coffee Break Python” email series, we take a pragmatic approach regarding Python code style — living in the “is” rather than in the “should be” world.
Can you solve the following puzzle about lambda functions?
# Python Puzzle fs = [ lambda x: x + 1, lambda x: x + x, lambda x: x * x, ] n = 0 for f in fs: n = f(n) print(n)
What’s the output of this code puzzle?
“Know Thyself and You Will Know the Universe”. ?
You need to know your Python skills before you can start improving them.
Discover your true Python potential and track your skill level online!
A puzzle a day to learn, code, and play…
As a Finxter premium member, your Python skills will soar:
- Unlimited Python puzzles
- Track your Python skill level over time
- Free courses on the Finxter Computer Science Academy:
- [Course] Object-oriented Python
- [Course] Intro to NumPy
- [Course] 10 Machine Learning Algorithms
- [Course] Python Crash Course
- Free printable Python certificates to proof your skills to your employer or your clients.
Accelerate your Python skills now with the proven approach of puzzle-based learning!
Become Finxter Premium Member.
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.