[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-697976-105":59,"doc-detail-697976-en":130,"doc-similar-697976":160},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","60001-lecture-5-tuples-lists-aliasing-mutability-cloning","6.0001 Lecture 5 - Tuples, Lists, Aliasing, Mutability, Cloning","","6.0001 Lecture 5 introduces compound data types and how sequences behave in Python, focusing on tuples and lists. It explains tuples as ordered, immutable collections with parentheses, covering indexing, slicing, concatenation, length, and the error when attempting in-place modification. The lecture then contrasts lists as mutable sequences denoted by square brackets, detailing indices, iteration patterns, element updates, and list boundaries. It also motivates related concepts: aliasing, mutability, and cloning.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/60001-lecture-5-tuples-lists-aliasing-mutability-cloning/697976/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/60001-lecture-5-tuples-lists-aliasing-mutability-cloning/697976.png","ImageObject",300,407,{"name":92,"@type":93},"Ezra","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-26","2026-11-12",true,{"@type":102,"interactionType":103,"userInteractionCount":34},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is the key difference between tuples and lists in this lecture?","Question",{"text":112,"@type":113},"Tuples are ordered sequences whose elements cannot be changed (immutable), while lists are mutable and their elements can be updated by index.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do slicing and indexing work for tuples?",{"text":117,"@type":113},"Tuple indexing retrieves a single element, while slicing returns a smaller tuple. For example, t[1:2] evaluates to (\"mit\",) and t[1:3] evaluates to (\"mit\",3).",{"name":119,"@type":110,"acceptedAnswer":120},"What does mutability imply for lists when assigning to an element?",{"text":121,"@type":113},"Because lists are mutable, assigning to L[index] changes the value stored in the same list object. The lecture notes it is the same object L after updating an element.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},697976,1794446554,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":34,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":129,"read_time":26,"preview_page_count":19,"preview_urls":144},1099514068035,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","TUPLES, LISTS, ALIASING, MUTABILITY, CLONING  \n(download slides and . py files and follow along!)   \n6.0001 LECTURE 5  \nLAST TIME  \n􀂃 functions  \n􀂃 decomposition – create structure  \n􀂃 abstraction – suppress details  \n􀂃 from now on will be using functions a lot  \nTODAY  \n􀂃 have seen variable types: int, float, bool,string  \n􀂃 introduce new compound data types  \n• tuples  \n• lists  \n􀂃 idea of aliasing  \n􀂃 idea of mutability  \n􀂃 idea of cloning  \nTUPLES  \n􀂃 an ordered sequence of elements, can mix element types  \n􀂃 cannot change element values, immutable   \n􀂃 represented with parentheses  \nte = ()  \nt = (2,\"mit\",3)  \nt[0] 􀃆 evaluates to 2  \n(2,\"mit\",3) + (5,6) 􀃆 evaluates to (2,\"mit\",3,5,6)  \nt[1:2] 􀃆 slice tuple, evaluates to (\"mit\",)  \nt[1:3] 􀃆 slice tuple, evaluates to (\"mit\",3) len (t) 􀃆 evaluates to 3  \nt[1] = 4 􀃆 gives error, can’t modify object  \nTUPLES  \n􀂃 conveniently used to swap variable values  \nx = yy = x  \ntemp = xx = yy = temp  \n(x, y) = (y, x)  \n􀂃 used to return more than one value from a function  \ndef quotient_and_remainder (x, y):  \nq = x // y  \nr = x % y  \nreturn (q, r)  \n(quot, rem) = quotient_and_remainder (4,5)  \nMANIPULATING TUPLES  \nmin_n = min(nums)  \nmax_n = max(nums)  \nunique_words = len (words)  \nreturn (min_n, max_n, unique_words)  \nLISTS  \n􀂃 ordered sequence of information, accessible by index  \n􀂃 a list is denoted by square brackets, []  \n􀂃 a list contains elements  \n• usually homogeneous (ie, all integers)  \n• can contain mixed types (not common)  \n􀂃 list elements can be changed so a list is mutable  \nINDICES AND ORDERING  \na  list = []   \nL = [2, 'a', 4, [1,2]]  \nlen (L) 􀃆 evaluates to 4  \nL[0] 􀃆 evaluates to 2  \nL[2]+1 􀃆 evaluates to 5  \nL[3] 􀃆 evaluates to [1,2], another list!  \nL[4] 􀃆 gives an error  \ni = 2  \n L[i-1] 􀃆 evaluates to ‘a’ since L[1]='a' above  \nCHANGING ELEMENTS  \n􀂃 lists are mutable!  \n􀂃 assigning to an element at an index changes the value L = [2, 1, 3]  \nL[1] = 5  \n􀂃 L is now [2, 5, 3], note this is the same object L  \n[2,5,3]  \nL  \nITERATING OVER A LIST  \n􀂃 compute the sum of elements of  \n􀂃 common pattern, iterate over list  \ntotal = 0  \nfor i in range(len (L)): total += L[i]  \nprint total  \na list elements  \ntotal = 0  \nfor  \ni  \nin  \nL:  \ntotal += i print total  \n􀂃 notice  \n• list elements are indexed 0 to len (L) -1  \n• range(n) goes from 0 to n-1","cbCainQvb3AJIjJW","https://ap.wps.com/l/cbCainQvb3AJIjJW","pdf",942084,24,"English","# 6.0001 Lecture 5\n## Tuples\n## Manipulating Tuples\n## Lists\n## Indices and Ordering\n## Changing Elements\n## Iterating Over a List","[{\"question\":\"What is the key difference between tuples and lists in this lecture?\",\"answer\":\"Tuples are ordered sequences whose elements cannot be changed (immutable), while lists are mutable and their elements can be updated by index.\"},{\"question\":\"How do slicing and indexing work for tuples?\",\"answer\":\"Tuple indexing retrieves a single element, while slicing returns a smaller tuple. For example, t[1:2] evaluates to (\\\"mit\\\",) and t[1:3] evaluates to (\\\"mit\\\",3).\"},{\"question\":\"What does mutability imply for lists when assigning to an element?\",\"answer\":\"Because lists are mutable, assigning to L[index] changes the value stored in the same list object. The lecture notes it is the same object L after updating an element.\"}]","6.0001 Lecture 5 - Tuples, Lists, Aliasing, Mutability, Cloning | PDF",[145,149,152,156],{"page_no":8,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/1076dde8dace4bfff1502ca704b51698.webp",983,736,{"page_no":14,"url":150,"width":151,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/652aa7e4a6e62bfdfe97fb12dec96a43.webp",982,{"page_no":81,"url":153,"width":154,"height":155},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/e30ac75e18f670d1ebae54b7a6a86682.webp",981,735,{"page_no":19,"url":157,"width":158,"height":159},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/ec9fa02d828fa8a9a264712f127d24a9.webp",980,734,{"list":161,"token":66},[162,168,174,180,185,191,197,203,209,215],{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":81,"category_name":30,"create_tm":167},685772,"UNIT-IV - LIST, TUPLES, DICTIONARIES - Problem Solving and Python Programming","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203776/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=ELQzwNoORaP6d44V9wJ4NdYw6n4%3D","unit-iv-list-tuples-dictionaries-problem-solving-and-python-programming",1794018219,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":19,"category_name":30,"create_tm":173},697980,"TUPLES AND DICTIONARIES - Introduction to Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146829/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=pj9%2FB72nnn1%2FTrQgbeNssX%2FS2so%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":29,"category_name":30,"create_tm":179},697978,"Lecture 4: Tuples, List Slicing, List Comprehension, Strings","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146771/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=MlhhJn%2FSU1JxMXeCK%2BrjxW%2BMmhs%3D","lecture-4-tuples-list-slicing-list-comprehension-strings",1794446559,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":34,"category_name":30,"create_tm":167},685773,"Lists and Tuples - Chapter 7 - Programming Concepts","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203784/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=l7Y3OK2BQbJJzYuhBqALHUPBvmY%3D","lists-and-tuples-chapter-7-programming-concepts",{"doc_id":186,"doc_title":187,"file_type":137,"home_preview_img_url":188,"slug":189,"view_count":29,"category_name":30,"create_tm":190},685629,"Chapter 2: Lists, Arrays and Dictionaries","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084017/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=3ZhsAK0WCTgE%2BKswO2eElaQVq2U%3D","chapter-2-lists-arrays-and-dictionaries",1794016092,{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":24,"category_name":30,"create_tm":196},685779,"Topic 6 - Lists, Sets, Tuples, Dictionaries","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203959/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=XLT11i2FjEQOLma4ErTcmNzDSUo%3D","topic-6-lists-sets-tuples-dictionaries",1794018231,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":24,"category_name":30,"create_tm":202},685635,"Lists, Tuples and Dictionaries - Lecture 10","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000169926/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=sD7%2BYiHBbyJZjVfpknHOBy7ItFo%3D","lists-tuples-and-dictionaries-lecture-10",1794016103,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":81,"category_name":30,"create_tm":208},685777,"Lists and Tuples - Learn to create and use 1D lists, tuples and 2D lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203949/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=inR1bGx3nCScreDhCClMj3dm7T8%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":210,"doc_title":211,"file_type":137,"home_preview_img_url":212,"slug":213,"view_count":34,"category_name":30,"create_tm":214},670917,"Python 3 Cheat Sheet - concise reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988704071/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=QAr7PtCDGgW0%2FIeCu6CeKxgg2go%3D","python-3-cheat-sheet-concise-reference",1793572698,{"doc_id":216,"doc_title":217,"file_type":137,"home_preview_img_url":218,"slug":219,"view_count":19,"category_name":30,"create_tm":220},685780,"Tuple in Python - Lecture 2","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203975/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796199359&Signature=bPmPeRs%2BBGw3h%2F5%2F9GDyU%2B8dlSg%3D","tuple-in-python-lecture-2",1794018232]