Type checking or hinting is a newer feature of Python that was added in Python 3.5. Type hinting is also known as type annotation. Type hinting is adding special syntax to functions and variable declarations that tell the developer what type the argument or variable is. Python does not enforce the type hints. You can […]
You will be using strings very often when you program. A string is a series of letters surrounded by single, double or triple quotes. Python 3 defines string as a "Text Sequence Type". You can cast other types to a string using the built-in str() function. In this article you will learn how to: Create […]
Dictionaries are another fundamental data type in Python. A dictionary is a key, value pair. Some programming languages refer to them as hash tables. They are described as a mapping object that maps hashable values to arbitrary objects. A dictionary's keys must be immutable, that is, unable to change. Starting in Python 3.7, dictionaries are […]
Tuples are another sequence type in Python. Tuples consist of a number of values that are separated by commas. A tuple is immutable whereas a list is not. Immutable means that the tuple has a fixed value and cannot change. You cannot add, delete or modify items in a tuple. Immutable objects are useful when […]
The original Python 101 was the first book I had ever written. In deciding to write a 2nd edition, I needed to decide what I should keep and what I should remove from the book. What I ended up doing was rewriting the book from the ground up. In the original book, Python 101 was […]
Lists are a fundamental data type in the Python programming language. A list is a mutable sequence that is typically a collection of homogeneous items. Mutable means that you can change a list after its creation. You will frequently see lists that contain other lists. These are known as nested lists. You will also see […]