Functions

What’s the Difference Between exit(0) and exit(1) in Python?

The function calls exit(0) and exit(1) are used to reveal the status of the termination of a Python program. The call exit(0) indicates successful execution of a program whereas exit(1) indicates some issue/error occurred while executing a program. What is the Exit Code? Let’s have a look at some examples to get a clear picture …

What’s the Difference Between exit(0) and exit(1) in Python? Read More »

Python Print Without Space

Problem Formulation Python’s print() function allows an arbitrary number of comma-separated values and prints them to the shell, separated by a single empty space character ‘ ‘. The following example shows how you pass four string values as arguments into the print() function: The resulting shell output has an added empty space character ‘ ‘ …

Python Print Without Space Read More »

How to Filter in Python using Lambda Functions?

To filter a list in Python, you can use the built-in filter() function. The first argument is the filtering condition, defined as a function. This filtering condition function is often dynamically-created using lambda functions. The second argument is the iterable to be filtered—the lambda function checks for each element in the iterable whether the element …

How to Filter in Python using Lambda Functions? Read More »

Understanding Generators In Python

If there is one subject in Python that creates confusion, it is that of generators. Generators are functions, but they have several differences from the ordinary functions you and I use daily. Today, we’ll be taking a gentle immersion into the world of generators to understand what they are, how they differ from ordinary functions, …

Understanding Generators In Python Read More »

An Introduction To Closures and Decorators in Python

Today’s tutorial will introduce two slightly more advanced concepts of closures and decorators in Python. We’ll explain what they are, how each is defined, and where and how they will help in your coding. Nested Functions I’m sure you are all familiar with functions, and some of you may have used, or heard of, nested …

An Introduction To Closures and Decorators in Python Read More »