Python Tutorial

Python JSON Tutorial: dumps, loads, dump, load, Pretty Print and Error Handling

Submitted by jaypabs on

JSON is everywhere in modern programming. REST APIs send it, JavaScript front ends expect it, configuration files are written in it, and many capstone projects store small amounts of data in a .json file before they move to a real database. If you write Python, sooner or later you will need to turn a dictionary into JSON or read a JSON response back into Python.

Python pathlib Tutorial: Paths, Read/Write, glob, mkdir and Practical File Scripts

Submitted by jaypabs on

Working with files is one of the first things you do in almost every Python project: open a CSV for a grade list, create a folder for uploads, find every .py file in a project, or build a path that works on both Windows and Linux. For years the usual tools were os.path and plain strings. Today the cleaner option is the built-in pathlib module and its Path objects.

Python Regex Tutorial: re.search, findall, sub and Validation with Examples

Submitted by jaypabs on

Sooner or later every programmer needs to find a pattern inside text: pull the dates out of a log file, check if an email address looks valid, clean up extra spaces in a name, or turn a title into a URL slug. You could write loops and if statements for each case, but there is a much shorter way: regular expressions (regex). Python supports them through the built-in re module, so there is nothing to install.

Python CSV Tutorial: Read, Write, Append and Filter CSV Files with the csv Module

Submitted by jaypabs on

CSV (comma-separated values) files are everywhere: exported Excel sheets, Google Forms responses, bank statements, grade sheets, product lists for an inventory system. Sooner or later every programmer has to read one, clean it, compute something and write a new file. In Python you do not need to install anything for that. The built-in csv module handles it, including the tricky parts like commas inside a field, quotes, different delimiters and Excel-friendly encodings.

Python Decorators Explained with Examples: Logging, Timing, Retry, Access Control and Caching

Submitted by jaypabs on

Have you ever seen a line like @app.route("/") in Flask or @login_required in Django and wondered what that little @ symbol actually does? That is a decorator, one of Python's most powerful features. A decorator lets you add extra behavior to a function, such as logging, timing, retrying or permission checks, without changing the function's own code.

How to Use itemgetter to Sort Dictionary Lists in Python

Submitted by razormist on

In this tutorial, we will learn how to program "How to Use itemgetter to Sort Dictionary Lists in Python". The objective is to use the `itemgetter` function to sort a list of dictionaries. This tutorial will guide you step by step through the process of sorting dictionaries using `itemgetter`. By the end of this tutorial, you will have a solid understanding of how to implement this solution effectively in Python, helping you strengthen your problem-solving abilities and improve your coding skills.

How to Find Uncommon Words from Two Strings in Python

Submitted by razormist on

In this tutorial, we will learn how to program "How to Find Uncommon Words from Two Strings in Python". The objective is to find uncommon words from two strings. This tutorial will guide you step by step through the process of identifying uncommon words between two strings. By the end of this tutorial, you will have a solid understanding of how to implement this solution effectively in Python, helping you strengthen your problem-solving abilities and improve your coding skills.

How to Find Matrix Product in Python

Submitted by razormist on

In this tutorial, we will learn how to program "How to Find Matrix Product in Python". The objective is to find the matrix product. This tutorial will guide you step by step through the process of finding the matrix product. By the end of this tutorial, you will have a solid understanding of how to implement this solution effectively in Python, helping you strengthen your problem-solving abilities and improve your coding skills.

How to Calculate Cumulative Sum with itertools in Python

Submitted by razormist on

In this tutorial, we will learn how to program "How to Calculate Cumulative Sum with itertools in Python". The objective is to calculate the cumulative sum of a sequence using the `itertools` module. This tutorial will guide you step by step through the process of calculating cumulative sums. By the end of this tutorial, you will have a solid understanding of how to implement this solution effectively in Python, helping you strengthen your problem-solving abilities and improve your coding skills.

How to Print Duplicates from a List of Integers in Python

Submitted by razormist on

In this tutorial, we will learn how to program "How to Print Duplicates from a List of Integers in Python". The objective is to find and print duplicate integers from a list. This tutorial will guide you step by step through the process of identifying duplicates in a list of integers. By the end of this tutorial, you will have a solid understanding of how to implement this solution effectively in Python, helping you strengthen your problem-solving abilities and improve your coding skills.