Difference Between List, Tuple, Set and Dictionary in Python

Difference between list, tuple, set and dictionary in Python: Command Prompt output of all four types

Four brackets, four behaviors. The list vs tuple vs set vs dictionary in Python choice comes down to three questions: can it change, does it keep order, and does it allow duplicates? A list is changeable and ordered, and a tuple is fixed. A set keeps unique items only, while a dictionary maps keys to … Read more >>

Difference Between {} and [] in Python

Difference Between {} and [] Python

When I build a small reporting script, I often need two very different things: a sequence of report rows and a quick way to look up details by an ID. Python uses [] for one of those jobs and {} for the other, so choosing the wrong brackets can cause confusing errors later. The difference between {} and [] in Python looks small … Read more >>

How to Comment Out a Block of Code in Python

How to Comment Out a Block of Code in Python

When I troubleshoot a reporting script, I often need to temporarily turn off a few lines without deleting them. Maybe an email notification sends too early, a file-writing step needs testing, or I want to isolate a function that causes an error. To comment out a block of code in Python, add a # at … Read more >>

is None vs == None in Python: What’s the Difference?

is None vs == None in Python: Command Prompt output comparing both checks on None and on 0

Use is None. The difference between is None vs == None in Python is that is checks whether a name points to the one and only None object, while == asks the object’s __eq__ method, which a class can rewrite to say anything: I ran these snippets on Python 3.12.5, NumPy 2.5.3 and pandas 3.0.6; … Read more >>

How to Use Single and Double Quotes in Python

Use Single and Double Quotes in Python

A small reporting script often starts with simple labels such as customer names, status messages, and file paths. Then someone adds a name like O’Connor or a message with double quotes, and Python suddenly throws a syntax error. I have hit this problem many times while building automation scripts that read CSV files, create reports, … Read more >>

How to Convert a List to an Array in Python

Convert a List to an Array in Python

When I build small reporting scripts, I often start with a Python list. It is easy to collect daily sales, API response times, or file sizes in a list while the script runs. But once I need type-safe numeric storage or fast calculations, I convert that list into an array. The word “array” means different … Read more >>

How to Convert a Dictionary to an Array in Python

Convert a Dictionary to an Array in Python

Last month I was helping a small logistics company in Austin track quarterly bonuses for their 10-person warehouse team. Everything lived in a dictionary, employee names as keys, bonus amounts as values, because that’s the fastest way to store key-value pairs in Python. The problem showed up when their finance lead asked me to export that … Read more >>

How to Read a Binary File into a Byte Array in Python

Read a binary file into a byte array in Python with bytearray and Path.read_bytes()

To read a binary file into a byte array in Python, use bytearray(Path(“file.bin”).read_bytes()), or open the file in “rb” mode and wrap f.read() in bytearray(). read() gives you immutable bytes; bytearray is the mutable version you can change and write back. This guide also covers reading byte by byte, reading large files in chunks, readinto(), … Read more >>

How to Create Arrays in Python: A Practical Guide

How to Create Arrays in Python

I built a simple leave request app for a small U.S. team after our HR person kept tracking time off in a messy Excel sheet. I wanted a local Python tool that ten employees across Dallas, Chicago, and Seattle could use from the command line, with approved requests saved permanently in SQLite. Along the way, … Read more >>

How to Find the Maximum Value in Python Using max()

Find the Maximum Value in Python Using max()

I still remember the week I stopped tracking leave in a shared Excel file. I once helped a 10-person U.S. team whose HR tracker kept breaking, since someone overwrote someone else’s row or forgot to update a formula every month. So I built a tiny Python command-line app to log leave requests, backed by a … Read more >>