[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685780-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-685780-en":130,"doc-similar-685780":154},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","tuple-in-python-lecture-2","Tuple in Python - Lecture 2","","Tuple in Python lecture notes introduce tuples as comma-separated collections and highlight key characteristics: similarity to lists but immutability of tuple elements after assignment. The material explains tuple creation, including use of parentheses and the optional parentheses best practice, creation without parentheses via tuple packing, and the rules for packing and unpacking with matching variable counts. It further covers single-element tuples, index-based access including negative indexing, slicing with colon notation, and the difference between mutable nested contents versus overall immutability, using list-versus-tuple examples and reference concepts.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/tuple-in-python-lecture-2/685780/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/tuple-in-python-lecture-2/685780.png","ImageObject",300,407,{"name":42,"@type":43},"นรินทร์","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-15","2026-11-07",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What is a tuple in Python, and how is it different from a list?","Question",{"text":62,"@type":63},"A tuple is a collection of Python objects separated by commas. Unlike lists, tuple elements cannot be changed after assignment because tuples are immutable.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How do you create a tuple in Python?",{"text":67,"@type":63},"A tuple is created by placing items inside parentheses separated by commas, though parentheses are optional. A tuple can also be created without parentheses using tuple packing.",{"name":69,"@type":60,"acceptedAnswer":70},"How does tuple packing and unpacking work?",{"text":71,"@type":63},"Tuple packing creates a new tuple from values, while unpacking extracts tuple values into variables. During unpacking, the number of variables on the left must match the number of values in the tuple.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},685780,1794018232,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":79,"read_time":144,"preview_page_count":26,"preview_urls":145},2336475104957,"https://ap-avatar.wpscdn.com/avatar/22000c4c6bd8a5076e1?x-image-process=image/resize,m_fixed,w_180,h_180&k=1787554080175789136","Tuple in Python  \n• A Tuple is a collection of Python objects separated by commas.  \n• A tuple in Python is similar to a list. The difference between the two is that we cannot change the elements of a tuple once it is assigned whereas, in a list, elements can be changed i.e. a tuple is immutable unlike lists which are mutable.  \nCreating a Tuple  \n• A tuple is created by placing all the items (elements) inside parentheses (), separated by commas. The parentheses are optional, however, it is a good practice to use them.  \n• A tuple can have any number of items and they may be of different types (integer, float, list, string, etc. ) .  \nCreating a Tuple  \n• A tuple can also be created without using parentheses. This is known as tuple packing.  \n• Packing and Unpacking a Tuple : In Python thereis a very powerful tuple assignment feature that assigns right hand side of values into left hand side. In other way it is called unpacking of a tuple of values into a variable. In packing, we put values into a new tuple while in unpacking we extract those values into a single variable.  \n• In unpacking of tuple number of variables on lefthand side should be equal to number of values in given tuple.  \nCreating a tuple with one element  \n• Having one element within parentheses is not enough. We will need a trailing comma to indicate that it is, in fact, a tuple.  \nAccess Tuple Elements  \n• We can use the index operator [] to access an item in a tuple where the index starts from 0 .  \n• So, a tuple having 6 elements will have indices from 0 to 5 .  \n• Python allows negative indexing for its sequences.  \n• The index of-1 refers to the last item, -2 to the second last item and so on.  \nSlicing  \n• We can access a range of items in a tuple by using the slicing operator-colon \":\" .  \nmy_tuple = ('p','r','o','g','r','a','m','i','z')  \n\\# elements 2nd to 4th  \n\\#Output: ('r', 'o', 'g') print(my_tuple[1:4])  \nSlicing  \n• Slicing can be best visualized by considering  \nthe index to be between the elements as shown below. So if we want to access a range, we need the index that will slice the portion from the tuple.  \nChanging a Tuple  \n• Unlike lists, tuples are immutable.  \n• This means that elements of a tuple cannot be changed once it has been assigned. But, if the element is itself a mutable datatype like list, its nested items can be changed.  \n• We can also assign a tuple to different values (reassignment) .  \nMutable vs Immutable i.e. (List vs  \nTuple)  \n• a variable is nothing but a reference to the actual python object in memory.  \n• The variable itself is not the object.  \nVariable and Python object  \n• a = [\"apples\", \"bananas\", \"oranges\"]  \n• When you do this, a python object of type list is created in the memory and the variable a refers to this object by holding its location in memory.","cbCaidCE5Rpua3KR","https://ap.wps.com/l/cbCaidCE5Rpua3KR","pdf",715521,13,"English","# Creating a Tuple\n## Tuple creation with parentheses\n## Creating a tuple without parentheses (tuple packing)\n## Creating a tuple with one element\n# Accessing and Slicing Tuple Elements\n## Index operator and negative indexing\n## Slicing using colon notation\n# Updating and Mutability Concepts\n## Tuples are immutable\n## Mutable nested datatypes in tuples\n## Variable as a reference to a Python object","[{\"question\":\"What is a tuple in Python, and how is it different from a list?\",\"answer\":\"A tuple is a collection of Python objects separated by commas. Unlike lists, tuple elements cannot be changed after assignment because tuples are immutable.\"},{\"question\":\"How do you create a tuple in Python?\",\"answer\":\"A tuple is created by placing items inside parentheses separated by commas, though parentheses are optional. A tuple can also be created without parentheses using tuple packing.\"},{\"question\":\"How does tuple packing and unpacking work?\",\"answer\":\"Tuple packing creates a new tuple from values, while unpacking extracts tuple values into variables. During unpacking, the number of variables on the left must match the number of values in the tuple.\"}]","Tuple in Python - Lecture 2 | PDF",33,[146,150],{"page_no":22,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/37f2dbce88dee47a16ed17635d3bb733.webp",983,737,{"page_no":26,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/a786c8eedde5bd36159c9698c88c385d.webp",982,736,{"list":155,"token":11},[156,162,168,174,180,186,192,198,204,210],{"doc_id":157,"doc_title":158,"file_type":137,"home_preview_img_url":159,"slug":160,"view_count":33,"category_name":29,"create_tm":161},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=1796111999&Signature=ndtMg7VKuh%2FVZnGgkoFg2qKMT3g%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":96,"category_name":29,"create_tm":167},685778,"1-Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203953/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=D3wxv0cFXXA2AOvXbuAWe7DbHJg%3D","1-tuples",1794018230,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":30,"category_name":29,"create_tm":173},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=1796111999&Signature=feqBrhzgjP%2FJCYUkxcuWW00ckxM%3D","unit-iv-list-tuples-dictionaries-problem-solving-and-python-programming",1794018219,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":101,"category_name":29,"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=1796111999&Signature=rwwZmmC7gwYmPKYiUIXUQjEmUKI%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":101,"category_name":29,"create_tm":185},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=1796111999&Signature=kREccyYa27NHolZjZpJfsR4Xbwk%3D","chapter-2-lists-arrays-and-dictionaries",1794016092,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":105,"category_name":29,"create_tm":191},697976,"6.0001 Lecture 5 - Tuples, Lists, Aliasing, Mutability, Cloning","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146768/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=ifyKtNbn2YC4beXkWXMFocXzzyY%3D","60001-lecture-5-tuples-lists-aliasing-mutability-cloning",1794446554,{"doc_id":193,"doc_title":194,"file_type":137,"home_preview_img_url":195,"slug":196,"view_count":96,"category_name":29,"create_tm":197},685631,"Introduction to List - List Operations - Traversing a List - List Methods and Built-in Functions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084036/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=sMRO%2BZcKYyfo9yetNMVF7USi7Cw%3D","introduction-to-list-list-operations-traversing-a-list-list-methods-and-built-in-functions",1794016095,{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":105,"category_name":29,"create_tm":203},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=1796111999&Signature=ihL%2FTMsBjTd6lOjac%2BtMSUrgsTI%3D","python-3-cheat-sheet-concise-reference",1793572698,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":30,"category_name":29,"create_tm":209},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=1796111999&Signature=gc%2B2npMvn6v8Fxr%2BQTfzF11871A%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":211,"doc_title":212,"file_type":137,"home_preview_img_url":213,"slug":214,"view_count":96,"category_name":29,"create_tm":215},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=1796111999&Signature=Ivzhs6oX%2BGDj6JR9WD2HpXbL11U%3D","topic-6-lists-sets-tuples-dictionaries",1794018231]