Python pass Statement: Stubs, Empty Blocks and Loops

Python pass statement: Command Prompt output of stub functions, a custom exception class and an if branch that use pass

The Python pass statement does nothing. It’s a placeholder you put where Python needs a statement but you have no code yet, like an empty function, class, loop or if branch. People often call it the pass function, but it’s a keyword: Each snippet here got tested with Python 3.12.5 inside a Windows Command Prompt, … Read more >>

How to Use the trim() Function in Python?

trim() Function in Python

In this tutorial, I will explain how to use the trim function in Python to clean up your strings. As a Python developer, while working on a project for a USA client, I often came across a situation where I needed to use the trim() function and explored various use cases of the trim() function. … Read more >>

How to Use the strip() Function in Python?

strip() Function in Python

In this tutorial, I will explain how to use the strip() function in Python. As a Python developer, while working on a project for a New York client, I encountered a situation where I needed to use the split() function and explored various uses of the split() function. Let us learn more about this topic … Read more >>

How to Implement and Use the hash() Functions in Python?

hash() Functions in Python

In this tutorial, I will explain how to implement and use hash() functions in Python. One of my team members asked this question and I decided to write a tutorial on this topic. Let us learn the implementation with examples and screenshots of the executed example code. hash() Function in Python A hash() function takes … Read more >>

How to Use the map() Function in Python

Python map() function: Command Prompt output of map() with a lambda over two lists

The Python map() function calls a function on every item of an iterable and gives you the results one at a time. Write map(function, iterable), then wrap it in list() when you want a list back: For the record, I tested these snippets with Python 3.12.5 (and Python 3.14.8 for the newer strict= keyword) on … Read more >>

Difference Between *args and **kwargs in Python

Difference between *args and **kwargs in Python: Command Prompt output of a function using both

The difference between *args and **kwargs in Python is what they collect. *args gathers any extra positional arguments into a tuple, while **kwargs gathers any extra keyword (name=value) arguments into a dictionary: Version check: Python 3.12.5, Windows Command Prompt. The output blocks are copied straight from those runs. In this tutorial, we’ll cover each one … Read more >>

Python randint(): Both Ends Included (and the NumPy Trap)

Python randint: the Command Prompt showing random.randint reaching 10 while NumPy's version stops at 9

randint returns a random whole number between two values, and unusually for Python, both ends are included: That inclusive upper bound is the thing to remember. range, slicing and randrange all stop one short, and randint does not. NumPy’s identically named np.random.randint does stop short, which is where most bugs come from. All output below … Read more >>

How to Use wait() Function in Python?

wait() function in Python

In this tutorial, I will explain how to use wait functions in Python. As a Python developer working on projects for clients in the USA, I frequently need to build in strategic delays and pauses. Effective use of Python wait functions allows you to control the flow and timing of your code. Let us see … Read more >>

Is Python a Good Language to Learn?

A bustling tech conference with Python logos, coding screens, and excited attendees

Python has become a popular choice for beginners in programming. Its simple syntax and readability make it easy to pick up. Many find Python’s code looks a lot like plain English. This helps new coders focus on problem-solving instead of complex language rules. Python is a versatile language that can be used in many fields, … Read more >>