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 ‘ ‘ … Read more

Python Return Dictionary From Function

Do you need to create a function that returns a dictionary but you don’t know how? No worries, in sixty seconds, you’ll know! Go! ? A Python function can return any object such as a dictionary. To return a dictionary, first create the dict object within the function body, assign it to a variable your_dict, … Read more

Python Return Tuple From Function

Do you need to create a function that returns a tuple but you don’t know how? No worries, in sixty seconds, you’ll know! Go! ? A Python function can return any object such as a tuple. To return a tuple, first create the tuple object within the function body, assign it to a variable your_tuple, … Read more

Python Return Set From Function

Do you need to create a function that returns a set but you don’t know how? No worries, in sixty seconds, you’ll know! Go! ? A Python function can return any object such as a set. To return a set, first create the set object within the function body, assign it to a variable your_set, … Read more

Python Return List

Do you need to create a function that returns a list but you don’t know how? No worries, in sixty seconds, you’ll know! Go! πŸ‘‡ Python Return List Basic A Python function can return any object such as a list. To return a list, first create the list object within the function body, assign it … Read more

Python Check Version of Package with pip

Problem Formulation Assuming you have the Python package manager pip installed in your operating system (Windows, Linux, macOS). How to check the version of a package with pip? Method 1: pip show To check which version of a given package is installed, use the pip show <your_package> command. For example, to check the version of … Read more

How to Find Outliers in NumPy Easily?

Can you spot the outliers in the following sequence: 000000001000000001? Detecting outliers fast can be mission critical for many applications in military, air transport, and energy production. This article shows you the most basic outlier detection algorithm: if an observed value deviates from the mean by more than the standard deviation, it is considered an … 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 … Read more