[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685778-105":59,"doc-detail-685778-en":130,"doc-similar-685778":149},{"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","1-tuples","1-Tuples","","Guide to Python tuples, explaining how they differ from lists through immutability and why constant data can be useful. Covers tuple creation with parentheses and commas, including empty and single-item tuples, and demonstrates accessing elements via zero-based indexing and negative indices. Includes tuple slicing syntax (start:end, start-only, end-only, and step slicing), shows how immutability prevents direct modification while enabling concatenation-based updates, and teaches membership testing, unpacking, nesting, and common methods like count() and index().",{"@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/1-tuples/685778/",{"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/1-tuples/685778.png","ImageObject",300,407,{"name":92,"@type":93},"Sarah ","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-19","2026-11-07",true,{"@type":102,"interactionType":103,"userInteractionCount":24},"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 Python?","Question",{"text":112,"@type":113},"Tuples are immutable, meaning their elements cannot be changed after creation.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you create an empty tuple and a single-item tuple?",{"text":117,"@type":113},"An empty tuple is created with (), while a single-item tuple requires a trailing comma, such as (42,).",{"name":119,"@type":110,"acceptedAnswer":120},"How does tuple slicing work in Python?",{"text":121,"@type":113},"Tuple slicing uses tuple[start:end] where start is inclusive and end is exclusive. You can also use forms like numbers[:3], numbers[5:], and numbers[::2] for step-based slicing.","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},685778,1794018230,{"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":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":34,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":143,"preview_page_count":8,"preview_urls":144},962085320529,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","1-Tuples  \nIn Python, tuples are similar to lists, but they have one key difference: tuples are immutable, meaning their elements cannot be changed once they are created. Tuples are useful when you want to ensure that the data remains constant throughout the program.  \nBelow is a comprehensive guide to Python tuples, including explanations, examples, and outputs.  \n1. Creating Tuples  \nTuples are created by placing elements inside parentheses () separated by commas.  \nExample:  \nPython Code  \n\\# Creating different types of tuples  \nempty_tuple = () \\# Empty tuple  \nsingle_item_tuple = (42,) \\# Single element tuple (note the comma) numbers_tuple = (1, 2, 3, 4, 5) \\# Tuple of integers  \nmixed_tuple = (1, \"apple\", 3.14) \\# Mixed data types  \nprint(empty_tuple)  \nprint(single_item_tuple)  \nprint(numbers_tuple)  \nprint(mixed_tuple)  \nOutput:  \n()  \n(42,)  \n(1, 2, 3, 4, 5)  \n(1, 'apple', 3.14)  \nExplanation:  \n• An empty tuple is created using empty parentheses () .  \n• To create a single element tuple, a trailing comma is required (e.g.,(42,)) .  \n• Tuples can contain elements of different types (integers, strings, floats, etc.) .  \n2. Accessing Tuple Elements  \nYou can access elements in a tuple by using indexing. Python uses zero-based indexing, meaning the first element has an index of 0.  \nExample:  \npython  \nCode  \nfruits = (\"apple\", \"banana\", \"cherry\")  \nprint(fruits[0]) \\# First item  \nprint(fruits[1]) \\# Second item  \nprint(fruits[-1]) \\# Last item (using negative indexing)  \nOutput:  \nCode apple banana cherry  \nExplanation:  \n• The index 0 accesses the first element (\"apple\") .  \n• The index-1 accesses the last element (\"cherry\") using negative indexing.  \n3. Tuple Slicing  \nJust like lists, you can slice tuples to extract specific portions ofthe tuple using the syntax tuple[start:end], where start is inclusive and end is exclusive.  \nExample:  \nPython Code  \nnumbers = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)  \nprint(numbers[2:5]) \\# Elements from index 2 to 4  \nprint(numbers[:3]) \\# Elements from the start to index 2  \nprint(numbers[5:]) \\# Elements from index 5 to the end print(numbers[::2]) \\# Every second element  \nOutput:  \nscss Code (2, 3, 4)  \n(0, 1, 2)  \n(5, 6, 7, 8, 9)  \n(0, 2, 4, 6, 8)  \nExplanation:  \n• numbers[2:5]: Extracts elements from index 2 to 4 (index 5 is excluded) .  \n• numbers[::2]: Extracts every second element.  \n4. Modifying Tuples  \nTuples are immutable, meaning their elements cannot be changed after the tuple is created. However, you can create a new tuple based on the old one.  \nExample:  \nPython Code  \nfruits = (\"apple\", \"banana\", \"cherry\")  \n\\# Attempt to modify a tuple (this will raise an error)  \n\\# fruits[0] = \"pear\" \\# Uncommenting this line will raise a TypeError  \n\\# Creating a new tuple by concatenation new_fruits = (\"pear\",) + fruits[1:] print(new_fruits)  \nOutput:  \n('pear', 'banana', 'cherry')  \nExplanation:  \n• Since tuples are immutable, you cannot directly modify the contents ofa tuple. However, you can create a new tuple by concatenating parts of the original tuple.  \n5. Tuple Concatenation and Repetition  \nYou can concatenate multiple tuples using the + operator and repeat tuples using the * operator.  \nExample:  \nPython Code tuple1 = (1, 2, 3)  \ntuple2 = (4, 5, 6)  \n\\# Concatenation  \nconcatenated_tuple = tuple1 + tuple2 print(\"Concatenated:\", concatenated_tuple)  \n\\# Repetition  \nrepeated_tuple = tuple1 * 2 print(\"Repeated:\", repeated_tuple)  \nOutput:  \nConcatenated: (1, 2, 3, 4, 5, 6)  \nRepeated: (1, 2, 3, 1, 2, 3)  \nExplanation:  \n• The + operator concatenates tuple1 and tuple2 .  \n• The * operator repeats the elements of tuple1 twice.  \n6. Checking for Membership in Tuples  \nYou can use the in keyword to check whether a specific element exists in a tuple.  \nExample:  \nPython Code  \nfruits = (\"apple\", \"banana\", \"cherry\")  \nif \"banana\" in fruits:  \nprint(\"Banana is in the tuple.\")  \nelse:  \nprint(\"Banana is not in the tuple.\")  \nOutput:  \nBanana is in the tuple.  \nExplanation:  \n• The ","cbCaikE4lJzLGU32","https://ap.wps.com/l/cbCaikE4lJzLGU32","pdf",226907,"English","# Tuples in Python\n## Creating Tuples\n## Accessing Tuple Elements\n## Tuple Slicing\n## Modifying Tuples\n## Concatenation and Repetition\n## Membership Testing\n## Tuple Unpacking\n## Nesting Tuples\n## Tuple Methods","[{\"question\":\"What is the key difference between tuples and lists in Python?\",\"answer\":\"Tuples are immutable, meaning their elements cannot be changed after creation.\"},{\"question\":\"How do you create an empty tuple and a single-item tuple?\",\"answer\":\"An empty tuple is created with (), while a single-item tuple requires a trailing comma, such as (42,).\"},{\"question\":\"How does tuple slicing work in Python?\",\"answer\":\"Tuple slicing uses tuple[start:end] where start is inclusive and end is exclusive. You can also use forms like numbers[:3], numbers[5:], and numbers[::2] for step-based slicing.\"}]","1-Tuples | PDF",18,[145],{"page_no":8,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/4a66251979445a062ea592e9058eeb1f.webp",983,1390,{"list":150,"token":66},[151,157,163,169,175,181,187,193,199,204],{"doc_id":152,"doc_title":153,"file_type":137,"home_preview_img_url":154,"slug":155,"view_count":19,"category_name":30,"create_tm":156},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":158,"doc_title":159,"file_type":137,"home_preview_img_url":160,"slug":161,"view_count":19,"category_name":30,"create_tm":162},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=1796111999&Signature=tpz81tw8DAmjuqvzC35DzDextZc%3D","tuple-in-python-lecture-2",1794018232,{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":29,"category_name":30,"create_tm":168},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":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":34,"category_name":30,"create_tm":174},685771,"Compound Data - Lists, Tuples, Dictionaries - Unit IV - Learning Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203726/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=F7DLudLeL7w0ZXnUPDQvD7bq7Ok%3D","compound-data-lists-tuples-dictionaries-unit-iv-learning-notes",1794018217,{"doc_id":176,"doc_title":177,"file_type":137,"home_preview_img_url":178,"slug":179,"view_count":34,"category_name":30,"create_tm":180},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":182,"doc_title":183,"file_type":137,"home_preview_img_url":184,"slug":185,"view_count":81,"category_name":30,"create_tm":186},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":188,"doc_title":189,"file_type":137,"home_preview_img_url":190,"slug":191,"view_count":19,"category_name":30,"create_tm":192},685627,"List in Python - A Beginner Guide -","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000169755/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=Of4sKV%2Fu1g%2FGhW%2FTpdD3Z%2BXiBZ8%3D","list-in-python-a-beginner-guide",1794016087,{"doc_id":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":81,"category_name":30,"create_tm":198},697979,"OCaml Introduction: Tuples and Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146792/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=Zmk4cNbp4kMY4kTF%2B9AeYLspcy0%3D","ocaml-introduction-tuples-and-lists",1794446560,{"doc_id":200,"doc_title":201,"file_type":137,"home_preview_img_url":202,"slug":203,"view_count":34,"category_name":30,"create_tm":186},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=1796111999&Signature=kx6s1pNU36hyyYlAEUNFYt5aGXc%3D","lists-and-tuples-chapter-7-programming-concepts",{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":81,"category_name":30,"create_tm":180},697975,"Python Variable Types - Variable Assignment, Multiple Assignment, and Standard Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146715/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=%2BmcA6ERW4OuXSQFq4SbeMbNyzY4%3D","python-variable-types-variable-assignment-multiple-assignment-and-standard-data-types"]