Home
k0nze
Cancel

What is Python __name__ == "__main__"?

thumbnail
You might have seen the Python line if __name__ == "__main__": in several code examples and wonder what does it do? Many other programming languages such as Java or C/C++ require a main function as the starting point for an application. However, in Python you can type some lines of code in a file, and...

Python Course #18: Your First Sorting Algorithm (Insertion Sort Explained)

thumbnail
With the knowledge of Python functions and algorithms, we are ready to write our first sorting algorithm and also take a closer look at how fast it runs. What is a Sorting Algorithm A sorting algorithm’s purpose is to reorder a list of elements based on a comparison criterion. This criterion is usually a less...

Python Course #17: What is an Algorithm

thumbnail
You probably hear the term algorithm a couple of times a week. YouTubers especially like to praise or blame “the algorithm” for their success or failure. In this article, I want to go a little more in-depth and explain what an algorithm is and what it can do for you. From a very abstract point...

Python Course #16: Functions

thumbnail
Up until now you have used a lot of functions already, most prominently the print(...) function. Now it is time to write your own functions in Python. What is a function in Programming? A function is a piece of code that is responsible for carrying out a task. Functions encapsulate several lines of code into...

Python Course #15: Reading and Writing Files

thumbnail
So far, you can store data within the variables of a program; however, when the program ends, this data is gone. And when you start the program again, all the data you want to work with has to be entered again. To store data throughout multiple runs of a program (or, to be correct, persist...

What is an NFT? A Computer Scientist's Perspective

thumbnail
NFTs have been all the rage for some time now. Twitter just introduced an NFT profile pictures where you can set your Twitter profile picture to an image that is “linked” to an NFT you own. But what are NFTs? And what can you do with those besides all the scams that are going around...

Python Course #14: User Input

thumbnail
Now that you know how to use for and while loops in Python, you can start getting input from outside of your program. In this article, you will learn how to capture a user’s input and build a small calculator in Python. Python input() Python provides a straightforward way to get input from a user...

Python Course #13: Loops

thumbnail
Up until now, the control flow of your programs was only from top to bottom. However, when writing more complex programs, it is often necessary to execute a specific piece of code several times in a row, and this is where loops come into play. Python While Loops Python (and many other programming languages) offers...

Change Windows 10/11 Display Resolution with a Python System Tray Application

thumbnail
Suppose you have to change your display resolution reasonably often. In that case, it can be a bit tiring to open the Windows display settings, choose the preferred resolution and confirm that you want to keep this resolution. But you can circumvent the Windows display settings with a small Python script. TL;DR You can find...

Python Course #12: Pass by Assignment, Copy, Reference, and None

thumbnail
Now that the you know what mutable (e.g. lists, sets and dictionaries) and immutable data types (e.g. tuples) are it is important to talk about copies, references and None. Python Pass by Assignment When you call a pass data to a function such as print(...) there are two ways. The first option is to pass...