How to Detect Lowercase Letters in Python?

Problem Formulation Given a string s. How to get a Boolean value that indicates whether all characters in the string are lowercase? Example: Say, you ask the user for input and you want to check whether all input characters are lowercase for further processing: If the user types in ‘alice’, the function should return True … Read more

Python OpenCV Image Processing – Resize, Blend, Blur, Threshold, Convert

This tutorial is an introduction to the OpenCV library. Learn how to convert color channels, resize, blend, blur, and threshold images in Python. The OpenCV [1] library contains most of the functions we need for working with images. Handling images in programming requires a different intuition than handling text data. An image is made up … Read more

Python random.seed() -A Deep Dive

[toc] Introduction random is an in-built module in Python which generates pseudo-random numbers. Now, the random data generated by this module is not completely random. Instead it is pseudo-random, as mentioned previously. Note: A “True Random Number” can be generated by a TRNG (true random number generator) while a “pseudo-random number” is generated by a … Read more

Are Python Lambda Functions All Greek To You?

Learn to Love Your Lambda! Lambda functions in python are simple one-line functions without a name (and therefore called an anonymous function) that can take many arguments but will only evaluate a single expression. They’re fast, short, and simple and can help you write cleaner β€˜more pythonic’ code. If like me you wanted to learn … Read more

Python String zfill()

Fills the string from the left with “0” characters. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.zfill(width) Fills the string from the left with “0” characters. width – the length of the resulting string. Although it works for … Read more

Python String upper()

Returns an uppercase string version. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.upper() Returns an uppercase string version (copy) whereas each character is replaced with its uppercase variant: Application String Upper – Ignoring String Case An application of … Read more

Python String translate()

Returns a translated string. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.translate(table) Returns a translated string that is a copy of the original string whereas only the character translations defined in the table argument have been applied to … Read more

Python String title()

Python’s built-in string.title() method returns a new string that has uppercase first characters for each word. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.title() Returns a new string with uppercase first characters of each word. πŸ’‘ Info: A … Read more

Python String swapcase()

Swaps lowercase to uppercase characters and vice versa. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.swapcase() Swaps lowercase to uppercase characters and vice versa. Note: Although you may expect that swapcase() is its own inverse function, this is … Read more

Python String strip()

Trims whitespaces on the left and right and returns a new string. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.strip([chars]) Trims whitespaces on the left and right and returns a new string. chars – optional. The argument defines … Read more