Python Dictionary – The Ultimate Guide

Python comes with several built-in data types. These are the foundational building blocks of the whole language. They have been optimised and perfected over many years. In this comprehensive tutorial, we will explore one of the most important: the dictionary (or dict for short). For your convenience, I’ve created a comprehensive 8000-word eBook which you … Read more

Python Functions and Tricks Cheat Sheet

Python cheat sheets are the 80/20 principle applied to coding: learn 80% of the language features in 20% of the time.Download and pin this cheat sheet to your wall until you feel confident using all these tricks. Download PDF for Printing Try It Yourself: Exercise: Modify each function and play with the output! Here’s the … Read more

Introduction to Slicing in Python

Slicing is a concept to carve out a substring from a given string. Use slicing notation s[start:stop:step] to access every step-th element starting from index start (included) and ending in index stop (excluded). All three arguments are optional, so you can skip them to use the default values (start=0, stop=len(lst), step=1). For example, the expression … Read more

Matplotlib Subplot – A Helpful Illustrated Guide

Too much stuff happening in a single plot? No problem—use multiple subplots! This in-depth tutorial shows you everything you need to know to get started with Matplotlib’s subplot() function. If you want, just hit “play” and watch the explainer video. I’ll then guide you through the tutorial: To create a matplotlib subplot with any number … Read more

Python Numpy 101: How to Calculate the Row Variance of a Numpy 2D Array?

You can play with the following interactive Python code to calculate the variance of a 2D array (total, row, and column variance). Here’s another practical example: What is the output of this puzzle?*Advanced Level* (solution below) Numpy is a popular Python library for data science focusing on arrays, vectors, and matrices. This puzzle introduces a … Read more

How to Calculate Variance of Python NumPy Arrays?

Numpy is a popular Python library for data science focusing on arrays, vectors, and matrices. Did you already learn something new today? Let’s master the popular variance function in NumPy! Problem: How to calculate the variance of a NumPy array? Solution: To calculate the variance of a Python NumPy array x, use the function np.var(x). … Read more