Category python-examples

Python array data structure

Python Array Data Structure. Arrays are a basic data structure found in most programming languages and are widely used in many algorithms. This section introduces some array implementations in Python. These arrays only use core features of the language or…

Python string formatting

The “Zen of Python” teaches us to use only one, well-defined way to do something. It can be confusing to discover that there are four main methods for string formatting in Python. This section explains how these four string formatting…

Python list slicing tricks

Python List Slicing Techniques, Python list objects have a convenient slicing feature. Slicing can be considered an extension of the square bracket indexing syntax and is often used to access a range of elements in an ordered collection. For example,…

Python generators

Python Generators, we spent a lot of time writing class-based iterators in the Python Iterator Tips section. While it’s fine from a teaching perspective, as you can see from the examples, writing this iterator class requires a lot of boilerplate…