How To Use Python’s Assert Keyword: Examples and Common Errors

Writing sanity checks is a practice as old as programming itself.  These checks involve checking whether certain assumptions, such as calculations, remain valid as a developer continues to build their program. If an assertion becomes false, it indicates to the developer(s) that there’s a bug in the program.  These tests are more formally known as […]

Read More

What Is a Subprocess in Python? (And How to Use It)

Command-line scripting can be a powerful approach to Python, but like all good things in programming, it can get complicated. Whether you’re looking to simply script on the command line or just want to use Python alongside command-line or other applications, you’ll benefit from learning about the subprocess module. You can do everything from running […]

Read More

Append In Python: How to Use Python List Append

The Stack Overflow Developer Survey 2022 confirmed that roughly six out of ten people learning to code begin their programming journey with Python.  And it’s no wonder – Python is concise, easy to read, and object-oriented. It offers everything you’d expect a modern programming language to bring to the table. Adding items to lists is […]

Read More

How to Use the Python Filter Function

The filter() function is a part of Python’s standard library. It is used to extract elements out of an iterable if they satisfy a supplied condition. The process of extracting elements this way is known as filtering.  After carrying out the filtering operation, the filter() function generates a new iterable holding the elements that satisfy […]

Read More

A Guide to Python’s += Operator

When writing a program in Python, there’s a good chance you will need to add two values and save the resulting value in a variable at some point.  Doing this is pretty straightforward, even if you don’t have much experience programming. But the nice thing is that Python provides an operator to accomplish this quickly. […]

Read More

Pandas Data Frame: A Tutorial for Creating and Manipulating Data

Pandas DataFrames are data structures that hold data in two dimensions, similar to a table in SQL or an Excel spreadsheet, but faster and more powerful. They have rows and columns and also have labels corresponding to these rows and columns.  DataFrames are an invaluable tool that form the bedrock of machine learning, data science, […]

Read More

How To Round Numbers in Python: Easy Steps

Python is considered one of the easier programming languages to learn and boasts a massive standard library. Not to mention, it supplies the flexibility to approach problems in different ways.  Case in point: rounding a number. There are a few different ways you can round a number in Python. In this post, we will look […]

Read More

How To Reset Index in A Pandas DataFrame (Fast and Easy)

The tabular structures in the Python pandas library are also termed DataFrames.  These structures represent the rows and columns using labels. A row label is called an index, and a column label is called a column index/header. DataFrames are created by filtering and manipulating large datasets. But these processed DataFrames have the same index as […]

Read More

How To Use Argparse to Write Command Line Programs: Examples and Tips

Command-Line Interfaces are the most straightforward interfaces, with their use reaching back decades around when the first modern computers were built.  Although Graphical User Interfaces have become commonplace, CLIs continue to be used today. They facilitate several Python operations, such as systems administration, development, and data science.  If you’re building a command-line app, you will […]

Read More

How To Use Python Version Management with Pyenv

Ever thought about how development teams contribute to projects that support several versions of Python? Testing a project across multiple Python versions seems like a massive chore when you think about it. But thankfully, in reality, it’s very easy to do. You can manage multiple Python versions with relative ease using pyenv.  In this guide, […]

Read More