Chris

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. He's author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, 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.

[Google Interview] Find the k-th Largest Element in an Unsorted Array

Do you train for your upcoming coding interview? This question was asked by Google as reported in multiple occasions by programmers all around the world. Can you solve it optimally? Let’s dive into the problem first. Problem Formulation Given an integer array or Python list nums and an integer value k. Find and return the …

[Google Interview] Find the k-th Largest Element in an Unsorted Array Read More »

How to Print a Percentage Value in Python?

To print a percentage value in Python, use the str.format() method or an f-string on the format language pattern “{:.0%}”. For example, the f-string f”{your_number:.0%}” will convert variable your_number to a percentage string with 0 digits precision. Simply run those three basic statements in your shell: your_number = 0.42 percentage = “{:.0%}”.format(your_number) print(percentage) As a …

How to Print a Percentage Value in Python? Read More »

16 PDF Cheat Sheets for Programmers

A couple of years ago, I fell into the habit of creating cheat sheets when exploring certain areas in the programming space. Over time, hundreds of thousands of Finxters have downloaded and used them in their own learning journeys. However, the cheat sheets are largely scattered around many different locations on the Finxter ecosystem. And …

16 PDF Cheat Sheets for Programmers Read More »

Python Regex to Return String Between Parentheses

Problem Formulation Given a string s. How to find the substring s’ between an opening and a closing parentheses? Consider the following examples: Input: ‘Learn Python (not C++)’ Output: ‘not C++’ Input: ‘function(a, b, c, d)’ Output: ‘a, b, c, d’ Input: ‘(a+(b+c))’ Output: ‘a+(b+c)’ Method 1: Slicing and str.find() The simplest way to extract …

Python Regex to Return String Between Parentheses Read More »

A Simple Example of Python Objects and Classes [+Video]

In Python, everything is an object. Even integers are objects — this is different from programming languages like Java where integers, floats, and Booleans are primitive data types. In this way, Python is built on a rigorously consistent object-oriented paradigm. Considering that objects are everywhere in Python, object-oriented programming is not well studied by Python …

A Simple Example of Python Objects and Classes [+Video] Read More »

Static and Dynamic Attributes in Python – What’s the Difference?

Quick Answer: Static attributes are variables defined once for the class and shared by all instances. Dynamic attributes are variables defined for individual instances only. Static variables are used as a “fall-back” when there are no explicit dynamic attributes defined for the instances. When you try to “overwrite” a static attribute such as in x.attr …

Static and Dynamic Attributes in Python – What’s the Difference? Read More »