CMPT 120 Lecture : Mutability
41 views1 pages
20 Oct 2011
School
Department
Course
Professor
![CMPT 120 Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2242525-class-notes-ca-sfu-cmpt-120-lecture27.jpg)
29
CMPT 120 Full Course Notes
Verified Note
29 documents
Document Summary
Data structures that can be modified inplace like this are mutable mystr = mystr + x , others are immutable, so are dictionaries, sets, objects (if they have methods that modify. Lists are mutable: so are numbers, boolean, tuples , objects (without modifying instances, strings are immutable methods eg. card, date, consider these statements: string = string + x list = list + [0] list. append(0) Mutability mylist[3] = xyz mylist. append(18: strings can"t do this. Lists are the only type we"ve seen that can be changed without totally rebuilding.
Get access
Grade+
$40 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers