Python IDLE Syntax Highlighting

Python’s IDLE code editor comes with every standard Python installation in Windows, Linux, and macOS. You can use it right out of the box after installing Python on your computer. Related Article: How to Install Python? IDLE has a useful syntax highlighting feature that highlights different Python language features to help you grasp source code … Read more

Python iter() — A Simple Illustrated Guide with Video

Python’s built-in iter() function returns an iterator for the given object. For example, iter([1, 2, 3]) creates an iterator for the list [1, 2, 3]. You can then iterate over all elements in the iterator, one element at a time, in a for or while loop such as: for x in iter([1, 2, 3]). Basic … Read more

Check if All Characters of a String are Uppercase

Problem Formulation: How to check if all characters of a string are uppercase? Background: A string is a sequence of characters, and is amongst the most commonly used and popular data types in Python. Strings can be enclosed by either single or double quotes and are β€˜immutable’, meaning they can’t be changed once created. There … Read more

What’s the Double Colon :: Operator in Python?

Problem Formulation: What does the double colon string[::2] or sequence[3::4] mean in Python? >>> string[::2] You can observe a similar double colon :: for sequences: >>> lst = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> lst[::2] Answer: The double colon is a special case in Python’s extended slicing feature. The extended slicing … Read more

Best LLC Services for Your Freelance Business

If you don’t protect your castle, they’ll come after you. From teaching thousands of freelancer students, we know that many freelance developers fear that unhappy clients come after their personal assets. Everyone makes mistake and these mistakes can become quite costly when submitting freelance work to a client. You may wonder: Can you protect against … Read more

Python Float Decimal to Octal

Problem Formulation: Given a float number. How to convert it to octal representation? Examples: Consider the following desired conversions from float decimal numbers to their converted float octal numbers. input: 3.14 output: 3.1075 input: 0.01 output: 0.005 input: 12.325 output: 14.246 You can play with some examples here: Solution: The following code function float_to_octal() takes … Read more

Python open() Function — An 80/20 Guide By Example

Python’s built-in open() function opens a file and returns a file object. The only non-optional argument is a filename as a string of the file to be opened. You can use the file object to access the file content. For example, file_obj.readlines() reads all lines of such a file object. Here’s a minimal example of … Read more

How to Customize Multiple Subplots in Matplotlib

This article will cover a specific issue that most Python users encounter when using Matplotlib for plotting their graphs. I am talking about defining multiple subplots and being able to access and change their properties individually. In the following sections, we will see how to use the Matplotlib function .subplots() for generating multiple subplots and … Read more

Python super() – A Simple Illustrated Guide

Python’s built-in super() method returns a temporary object of the superclass to help you access its methods. Its purpose is to avoid using the base class name explicitly. It also enables your class to inherit from multiple base classes. Visual Idea super() The idea is simple: use super() to call the methods defined in the … Read more