COMPSCI 61A Lecture 12: Mutable Sequences

27 views2 pages
28 Jul 2016
School
Professor
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

To explore the power of values that can mutate, or change. Data abstraction allows us to think of compound/complex values as objects. Many compound values have state that changes over time (property of being mutable) Returns last element and removes it from list list. extend([sub-list]) Adds sub-list to the end of a list. Can"t be mutable values, such as lists and dictionaries. You can use a tuple as a dictionary key, but you can"t use a list (or a tuple that contains a list) as a dictionary key. Not only does your dictionary key have to be immutable, it must contain all immutable values. If you want to associate multiple values with a key, store them all in a sequence value. A function can change the value of any object in its scope. Even though an object is bound to something in the global frame, if it is referenced within a function it can be mutated in the global frame.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers