From the course: Programming Foundations: Real-World Examples
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Mutable and immutable data - Python Tutorial
From the course: Programming Foundations: Real-World Examples
Mutable and immutable data
- As you learn about programming, you might encounter two funny sounding words: mutable and immutable, which are just fancy words to describe whether or not something can be changed. A mutable object can be modified after it's been created, whereas an immutable object cannot. Once you've created an immutable object, you're stuck with it. Object types will either be mutable or immutable, and it's a good idea to learn which is which in your programming language, so you can be sure to select the right type of object for different jobs. For example, you'd want to avoid using immutable data types to store values in your program that we're going to constantly be changing or needing to be changed. One example of a mutable object in Python is the list, which is an object type that acts as a container to store an ordered collection of other objects. You can think of this rack of clothes as a list, which contains several different clothing objects. As Olivia sorts through the rack of clothes to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.