How to Print Colored Text in Python?

Summary: To print colored text in Python, you can use: The simple_color package, The ‘\033[1m’ ANSI escape-sequence, The termcolor module, The coloroma package, The colored library, The prompt_toolkit package. A simple, no-library way to print bolded text in Python is to enclose a given string s in the special escape sequence like so: print(“\033[38;5;4m”). We’ll … Read more

How to Extract Numbers from a String

Problem Formulation and Solution Overview In this article, you’ll learn how to extract numbers from a string in Python. To make it more fun, we have the following running scenario: This article references an Albanian proverb written by Driton Selmani in 2012. We will leave the interpretation up to you. πŸ’¬ Question: How would we … Read more

How to Print Italic Text in Python?

You can change your text to bold, italic, and underlined in Python. Not only can you play around with the style of your code but also change its color with the help of specific packages and modules in Python. Interesting! Isn’t it? There are different ways of doing this. By the end of this tutorial, … Read more

How to Print Bold Text in Python?

Summary: To print bold text in Python, you can use: The simple_color package, The ‘\033[1m’ ANSI escape-sequence, The termcolor module, The coloroma package, The prompt_toolkit package. A simple, no-library way to print bolded text in Python is to enclose a given string s in the special escape sequence like so: print(“\033[1m” + s + “\033[0m”). … Read more

How to Count Vowels in a String

Problem Formulation and Solution Overview In this article, you’ll learn how to count the number of vowels in a string. To make it more fun, we have the following running scenario: In Canada, we have a province called Saskatchewan. This province has a large amount of flat land. In this article, we reference their local … Read more

How to Suppress Scientific Notation in Python

Summary: Use the string literal syntax f”{number:.nf}” to suppress the scientific notation of a number to its floating-point representation. Problem Formulation: How will you suppress a number represented in scientific notation by default to a floating-point value? Note: Generally, Python represents huge floating-point numbers or very small floating-point numbers in their scientific form. Scientific notation … Read more

Python Base64 – String Encoding and Decoding [+Video]

A Short Guide to Base64’s History and Purpose Base64 is a system of binary-to-text transcoding schemas, which enable the bidirectional transformation of various binary and non-binary content to plain text and back. Compared to binary content, storage and transfer of textual content over the network is significantly simplified and opens many possibilities for flexible data … Read more