1️⃣

17.1 Mutability and Order

Mutability and Order

Before we dive in, let’s go over some important terms.

Mutable and immutable. An object (everything in Python is an object) is mutable if it can be changed after creation and immutable if it can’t be changed after creation. Examples of mutable objects: list, set, and dictionary. Examples of immutable objects: boolean, integer, floating-point, string, and tuple.

Ordered and unordered. Objects inside a data structure (a data structure is a storage format like a list) are considered ordered if there is some order in which the objects are stored in the data structure. This means you can index. Objects inside a data structure are considered unordered if there is no order in which the objects are stored. This means you cannot index.

⚖️

Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.