List Indexing

🛑 Note: Python has zero-based indexing, i.e., the index of the first element is 0, and the index of the i-th element is (i-1). This is a common source of bugs! What is the output of this code snippet? This puzzle introduces the simple but powerful list data structure in Python. You have to search … Read more

Set, Lambda, and Filter in Python

Social Media

What is the output of this code snippet? You will use or have already used the operations introduced in this puzzle. They are elementary pieces of knowledge for any Python programmer. First, we have the two dictionaries mapping an account name to the number of followers. For example, Cristiano Ronaldo (key: “@cristiano”) has 120 million … Read more

Parameter Passing in Python: Call By Object

What is the output of this code snippet? This puzzle demonstrates that parameters are called by object in Python. What does that mean? We look into two functions depreciation1 and depreciation2. The functions take an asset value or a list of asset values as inputs. They depreciate this value by multiplying it with the depreciation … Read more

String Indexing in Python (2-Min Tutorial)

What is the output of this code snippet? This puzzle introduces a powerful tool for your Python toolbox. Make sure, you feel comfortable using it because many advanced puzzles depend on it. The name of the tool is indexing. In Python, you can access every character in the string by using an integer value which … Read more

Python Division: A Short Guide

Python Division

What is the output of this code snippet? The majority of people solve this puzzle correctly. Even so, the first goal of this puzzle is to introduce the concept of variables. Python evaluates the result of the expression on the right side of the equation and stores it in the variable x. After defining the … Read more

Python Comments # 2-Minute Interactive Primer

What is the output of this code snippet? This puzzle introduces two basic concepts. First, variables can hold strings. In fact, variables can hold any data type. The interpreter determines the data type of a variable at runtime. The data type of a variable can change: you can assign a string to a variable, followed … Read more

A List of Lambda Functions? This Python Puzzle May Surprise You…

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 … Read more