Drill – List Comprehensions in Python
Time for a list comprehensions drill. In the previous two articles we were talking about list comprehensions. Let’s practice them… Read More »Drill – List Comprehensions in Python
Time for a list comprehensions drill. In the previous two articles we were talking about list comprehensions. Let’s practice them… Read More »Drill – List Comprehensions in Python
Today we’ll learn how to use list comprehensions to work with matrices. In particular we’ll be talking about matrix column… Read More »Matrix Column and Diagonal Retrieval with List Comprehensions
Today we’ll be talking about the list comprehension in Python. A list comprehension is used to create a list. It… Read More »List Comprehension in Python
Today we’ll see how to programmatically check a couple of things. In particular, we’ll be checking the version of the… Read More »Python Interpreter – Version, Path and Platform Check
To calculate a percent change, you can use the following formula: pc = (new – old) / old * 100%… Read More »How to Calculate a Percent Change Using Python
Today we’ll be talking about the reduce function, which, unlike the map and filter functions discussed in the previous articles,… Read More »Functional Programming in Python – the reduce Function
Today we’ll be talking about the filter function, which is, just like the map function, a built-in used in functional… Read More »Functional Programming in Python – the filter Function
Today we’ll be talking about the map function, which is a built-in used in functional programming. In the following two… Read More »Functional Programming in Python – the map Function
Today we’ll be talking about jump tables. These are structures containing functions, usually lists or dictionaries. We can choose the… Read More »Jump Tables in Python
Today we’ll be talking about function annotations. These are user-defined data that add some information to functions. Annotations add information… Read More »Function Annotations in Python
Today we’ll be talking about functions embedded in data structures. Here’s the video version of this article: In Python functions… Read More »Functions Embedded in Data Structures
Today we’ll be talking about functions in Python. Functions in Python are often described as first-class objects. It just means… Read More »Functions as First-Class Objects
Today we’ll be talking about lambda expressions that are used to return anonymous functions, so functions without a name. Here’s… Read More »Anonymous Functions and Lambda Expressions
Today we’ll be talking about recursive functions. Recursive functions are functions that call themselves. A typical example shown when recursion… Read More »Recursion and Recursive Functions in Python
In some of the recent articles we were talking about different aspects of argument passing in Python. Time for a… Read More »Drill – Function Arguments in Python
Today we’ll be talking about the order of arguments. If you haven’t read my article on argument matching modes in… Read More »The Order of Arguments
Today we’ll be talking about keyword-only arguments. If you haven’t read my article on argument matching modes in Python, it’s… Read More »Keyword-Only Arguments
Today we’ll be talking about passing arguments to functions in Python. In particular we’ll be talking about argument types and… Read More »Argument Types and Matching Modes in Python
Today we’ll be talking about the Counter class from the collections module. The Counter class is used to create an… Read More »The Counter Class from the collections Module
Today I have a short drill for you. It’s about passing mutable and immutable objects as arguments to functions. If… Read More »Drill – Mutable and Immutable Objects as Arguments
Today we’ll be talking about state retention across function calls. If you prefer to watch a video version, here it… Read More »State Retention Across Function Calls in Python
Today we’ll be talking about the nonlocal statement. This article is sort of complementary to my article on the global… Read More »The nonlocal Statement in Python
Today we’ll be talking about the global statement and global variables in Python. This article is sort of complementary to… Read More »The global Statement and Global Variables
Today we’ll discuss scopes. To start with, what is scope? Well, to keep it simple scope is the part of… Read More »Local, Nonlocal, Global and Built-in Variable Scope
Today we’ll be talking about saving the current value of a loop variable in functions nested in loops. Sounds more… Read More »Save Loop Variable’s Value in Functions Nested in Loops
Today we’ll be talking about closures, also known as factory functions. A closure is a function that remembers values in… Read More »Closures, aka Factory Functions in Python
Today our topic is: function in statement. Here’s the video version: Well, this is probably one of the topics you… Read More »Defining Function In Statement in Python
Today we’ll be talking about the PyDoc HTML reports, which can be used to read documentation in a more visual… Read More »PyDoc HTML Reports to Read Documentation
Today we’ll be talking about docstrings. Here’s the video version: Docstrings are used to document functions, classes and modules. They’re… Read More »How to Use Docstrings in Python
Today we’ll be talking about the multiple iterator and the single iterators. Here’s the video version: If you don’t feel… Read More »Multiple Iterator vs Single Iterator
Today we’ll be talking about the dictionary view. Actually, there are three of them, the keys view, the values view… Read More »Dictionary View: Keys, Values, Items
Today we’ll briefly discuss the two built-in functions: all and any. They are very handy and make our life easier,… Read More »The ALL and ANY Built-in Functions
Today we’ll be talking about the basics of the iteration protocol, and, to be more specific, about the concepts of… Read More »Iterable vs Iterator – What’s the Difference?
Today we’ll be talking about the else statement used in loops. You definitely know the else block from conditional statements… Read More »The else Statement in WHILE and FOR Loops
Today we’ll be talking about slicing strings. This is what you do if you need to make a substring from… Read More »Slicing Strings Using the Slice Operator in Python
Today we’ll be talking about using the string index in Python. Here’s the video version: As you know, strings are… Read More »How to Use the String Index in Python
Today we’ll be talking about Python boolean operators: and, or and not. In particular we’ll have a look at what… Read More »Boolean Operators in Python and What They Return
Today we’ll be talking about multiway branching, and, to be more precise, we’ll see how to cope with the fact… Read More »Multiway Branching – the Missing switch Statement
Today we’ll be talking about extended sequence unpacking. We’ll see how to assign the elements of a sequence to multiple… Read More »Extended Sequence Unpacking in Python
Today we’ll be talking about the notion of shared reference. What are shared references in Python? Multiple References to Immutable… Read More »Shared Reference with Mutable and Immutable Types
Today we’ll be talking about comparing the relative magnitudes of objects. Here you can watch the video version: It seems… Read More »Compare Objects in Python – Not Just Numbers
Today we’ll be comparing the == operator and the is operator. The former tests value equivalence, the latter tests object… Read More »Equality Checks (== vs the is Operator)
Today we’ll be talking about the named tuple. Here’s the video version if you feel like watching it first: Regular… Read More »Using the Named Tuple in Python
Today we’ll learn how to send text to file using the print function. Here’s the video version if you want… Read More »How to Send Text to File Using the print Function
Today we’ll be talking about sorting lists. We’ll be using the sort method and the built-in sorted function. If you… Read More »Sorting Lists with the sort and sorted Functions
Today we’ll be talking about slice assignment in Python. It works with lists, which are mutable. We’ll also learn how… Read More »Slice Assignment in Python – How Does It Work?
Today we’ll discuss some of the most used functions from the random module. They are used if you need random… Read More »Random Numbers and the random Module in Python
Today I’d like to show you how to copy a list in three different ways. We’ll be focusing on shallow… Read More »How to Copy a List in Python in Three Different Ways
Let’s have a look at the basic trig functions. How can you use them in calculations with Python? The three… Read More »Trig Functions in Python: sine, cosine, tangent
There are lots of built-in math functions in Python. If you don’t find the one you need, chances are that… Read More »Math Functions Often Used in Python
Although we usually use the decimal number, which is the one we learned in the very first years of our… Read More »Decimal Number vs Binary, Octal and Hexadecimal
Today we’ll see how to check the object type in Python. We’ll be making use of two functions: type and… Read More »How to Check the Object Type in Python
Today we’ll be talking about the nested list and dictionary. Nested lists and dictionaries are often used to better structure… Read More »Nested List and Dictionary Basics
Today we’ll see how to use the underscore sign to retrieve the last result, or, to be more precise, the… Read More »How to Retrieve the Last Result with Underscore
Today we’ll see how Python uses interning to help you cache memory. Object Identities First, let’s create two variables and… Read More »Cache Memory with Interning in Python
Today we’ll be talking about the print function, and to be precise, we’ll see how to print strings without the… Read More »How to Use the end Parameter in the print Function
Today we’ll see how to rename and move files in Python. Actually, it’s the same thing. First, let’s create a… Read More »How to Rename or Move Files in Python
Today we’ll be talking about fractions. Sometimes decimal fractions are not exactly what you want. You may want to operate… Read More »Fractions with the Python Fraction Type
We already talked about the dir function, which may come in really useful if you need to check an attribute… Read More »The Built-In help Function in Python
Sometimes you may need to check an object’s attributes. You can easily do it using the built-in dir function. You… Read More »The Built-In dir Function in Python