[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685773-105":3,"doc-detail-685773-en":81,"detail-sidebar-cat-0-en-105":119,"doc-similar-685773":164},{"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":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","lists-and-tuples-chapter-7-programming-concepts","Lists and Tuples - Chapter 7 - Programming Concepts","","Chapter 7 introduces Python sequence types with a focus on lists and tuples. It explains how sequences store multiple data items in order, the mutability difference between lists and tuples, and how to define lists using bracket notation. The chapter covers repetition and iteration over lists, indexing including negative indexes, retrieving length with len to avoid IndexError, and updating list elements through valid index assignment. It also previews tuple usage and list slicing and methods for processing list data and plotting it with matplotlib.",{"@graph":14,"@context":73},[15,34,56],{"@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/lists-and-tuples-chapter-7-programming-concepts/685773/",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/lists-and-tuples-chapter-7-programming-concepts/685773.png","ImageObject",300,407,{"name":42,"@type":43},"Connor ","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-18","2026-11-07",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",7,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What is the difference between a list and a tuple in Python?","Question",{"text":63,"@type":64},"A list is mutable, meaning its elements can be changed. A tuple is immutable, so its elements cannot be modified after creation.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do you iterate over a list in Python?",{"text":68,"@type":64},"Use a for loop such as \"for x in list:\" to process each element in sequence.",{"name":70,"@type":61,"acceptedAnswer":71},"How can len() help prevent errors when working with list indexes?",{"text":72,"@type":64},"len() returns the number of elements, so the last valid index is len(list) - 1. Using this value helps avoid an IndexError from invalid indexes.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},685773,1794018219,{"code":4,"msg":82,"data":83},"success",{"doc_id":79,"user_id":84,"nickname":42,"user_avatar":85,"doc_module":4,"category_id":86,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":87,"file_id":88,"file_url":89,"file_type":90,"file_size":91,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":92,"language":93,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":94,"faqs":95,"seo_title":96,"seo_description":12,"update_tm":80,"read_time":97,"preview_page_count":98,"preview_urls":99},687207022233,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d",6,"C H A P T E R 7  \nLists and Tuples  \nCopyright © 2018 Pearson Education, Inc.  \nTopics  \n• Sequences  \n• Introduction to Lists  \n• List Slicing  \n• Finding Items in Lists with the in Operator  \n• List Methods and Useful Built-in Functions  \nCopyright © 2018 Pearson Education, Inc.  \nTopics (cont’d.)  \n• Copying Lists  \n• Processing Lists  \n• Two-Dimensional Lists  \n• Tuples  \n• Plotting List Data with the matplotlib Package  \nCopyright © 2018 Pearson Education, Inc.  \nSequences  \n•  Sequence: an object that contains multiple items of data  \n• The items are stored in sequence one after another  \n• Python provides different types of sequences, including lists and tuples  \n• The difference between these is that a list is mutable and a tuple is immutable  \nCopyright © 2018 Pearson Education, Inc.  \nIntroduction to Lists  \n•  List: an object that contains multiple data items  \n•  Element: An item in a list  \n• Format: list = [ item1, item2, etc. ]  \n• Can hold items of different types  \n• print function can be used to display an entire list  \n• list() function can convert certain types of objects to lists  \nCopyright © 2018 Pearson Education, Inc.  \nIntroduction to Lists (cont’d.)  \nCopyright © 2018 Pearson Education, Inc.  \nThe Repetition Operator and Iterating over a List  \n•  Repetition operator: makes multiple copies of a list and joins them together  \n• The * symbol is a repetition operator when applied toa sequence and an integer  \n• Sequence is left operand, number is right  \n• General format: list * n  \n• You can iterate over a list using a for loop  \n• Format: for x in list:  \nCopyright © 2018 Pearson Education, Inc.  \nIndexing  \n•  Index: a number specifying the position of an element in a list  \n• Enables access to individual element in list  \n• Index of first element in the list is 0, second element is 1, and n’th element is n-1  \n• Negative indexes identify positions relative to the end of the list  \n• The index-1 identifies the last element, -2 identifies the next to last element, etc.  \nCopyright © 2018 Pearson Education, Inc.  \nThe len function  \n• An IndexError exception is raised if an invalid index is used  \n•  len function: returns the length of a sequence such as a list  \n• Example: size = len(my  list)  \n• Returns the number of elements in the list, so the index of last element is len(list) -1  \n• Can be used to prevent an IndexError exception when iterating over a list with a loop  \nCopyright © 2018 Pearson Education, Inc.  \nLists Are Mutable  \n• Mutable sequence: the items in the sequence can be changed  \n• Lists are mutable, and so their elements can be changed  \n• An expression such as  \n• list[1] = new value can be used to assign a new value to a list element  \n• Must use a valid index to prevent raising of an IndexError exception  \nCopyright © 2018 Pearson Education, Inc.","cbCaisAwtIukUKUw","https://ap.wps.com/l/cbCaisAwtIukUKUw","pdf",1411035,50,"English","# Sequences\n## Introduction to Lists\n## The Repetition Operator and Iterating over a List\n## Indexing\n## The len function\n## Lists Are Mutable","[{\"question\":\"What is the difference between a list and a tuple in Python?\",\"answer\":\"A list is mutable, meaning its elements can be changed. A tuple is immutable, so its elements cannot be modified after creation.\"},{\"question\":\"How do you iterate over a list in Python?\",\"answer\":\"Use a for loop such as \\\"for x in list:\\\" to process each element in sequence.\"},{\"question\":\"How can len() help prevent errors when working with list indexes?\",\"answer\":\"len() returns the number of elements, so the last valid index is len(list) - 1. Using this value helps avoid an IndexError from invalid indexes.\"}]","Lists and Tuples - Chapter 7 - Programming Concepts | PDF",126,5,[100,104,108,112,116],{"page_no":22,"url":101,"width":102,"height":103},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/86d769d4f9debe5064380b88864fd320.webp",983,737,{"page_no":26,"url":105,"width":106,"height":107},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/da99d1c4f65019947d77bd01657b4fce.webp",982,736,{"page_no":30,"url":109,"width":110,"height":111},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/fdf41635ec1d7c2ce24f530dc423276a.webp",981,735,{"page_no":33,"url":113,"width":114,"height":115},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/1e0ea4fe2b543afe96822faa3aafa91a.webp",980,734,{"page_no":98,"url":117,"width":118,"height":115},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/316a490a07f4874f0f6892d15213bd90.webp",979,{"code":4,"msg":82,"data":120},[121,125,129,133,137,139,143,148,153,156,160],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":122,"show_sort_weight":123,"slug":124},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":126,"show_sort_weight":127,"slug":128},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":130,"show_sort_weight":131,"slug":132},"Exam",70,"exam",{"id":98,"doc_module":4,"doc_module_name":25,"category_name":134,"show_sort_weight":135,"slug":136},"Comic",60,"comic",{"id":86,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":92,"slug":138},"technology",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":140,"show_sort_weight":141,"slug":142},"Healthcare",40,"healthcare",{"id":144,"doc_module":4,"doc_module_name":25,"category_name":145,"show_sort_weight":146,"slug":147},8,"Research & Report",30,"research-report",{"id":149,"doc_module":4,"doc_module_name":25,"category_name":150,"show_sort_weight":151,"slug":152},9,"Religion & Spirituality",20,"religion-spirituality",{"id":151,"doc_module":4,"doc_module_name":25,"category_name":154,"show_sort_weight":151,"slug":155},"World Cup","world-cup",{"id":157,"doc_module":4,"doc_module_name":25,"category_name":158,"show_sort_weight":157,"slug":159},10,"Lifestyle","lifestyle",{"id":161,"doc_module":4,"doc_module_name":25,"category_name":162,"show_sort_weight":98,"slug":163},19,"General","general",{"list":165,"token":11},[166,172,177,183,189,195,201,207,213,219],{"doc_id":167,"doc_title":168,"file_type":90,"home_preview_img_url":169,"slug":170,"view_count":33,"category_name":29,"create_tm":171},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=1796110919&Signature=0u5nxqjq2AH4pK0fTUhiWAK%2F0Is%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":173,"doc_title":174,"file_type":90,"home_preview_img_url":175,"slug":176,"view_count":30,"category_name":29,"create_tm":80},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=1796110919&Signature=jdHHqgxPoyq5B9vAjoMF6Dvp2xU%3D","unit-iv-list-tuples-dictionaries-problem-solving-and-python-programming",{"doc_id":178,"doc_title":179,"file_type":90,"home_preview_img_url":180,"slug":181,"view_count":55,"category_name":29,"create_tm":182},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=1796110919&Signature=P2oFzR%2FBWLcsUbRn0mNJd8vGkxY%3D","60001-lecture-5-tuples-lists-aliasing-mutability-cloning",1794446554,{"doc_id":184,"doc_title":185,"file_type":90,"home_preview_img_url":186,"slug":187,"view_count":86,"category_name":29,"create_tm":188},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=1796110919&Signature=WFo5cSBH0xw%2FYVmsAsKJdppdrgE%3D","lecture-4-tuples-list-slicing-list-comprehension-strings",1794446559,{"doc_id":190,"doc_title":191,"file_type":90,"home_preview_img_url":192,"slug":193,"view_count":86,"category_name":29,"create_tm":194},685634,"Python Collections - Arrays - List and Function","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084045/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110919&Signature=ajl3BoFbxDAy2LAyAw5ZkFnW%2FLE%3D","python-collections-arrays-list-and-function",1794016101,{"doc_id":196,"doc_title":197,"file_type":90,"home_preview_img_url":198,"slug":199,"view_count":33,"category_name":29,"create_tm":200},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=1796110919&Signature=DAD3QSSgsKbHdauW%2B7KHhUvi43g%3D","tuple-in-python-lecture-2",1794018232,{"doc_id":202,"doc_title":203,"file_type":90,"home_preview_img_url":204,"slug":205,"view_count":30,"category_name":29,"create_tm":206},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=1796110919&Signature=mpRsoDgvmE9s4Uz4yEfosaL1y5E%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":208,"doc_title":209,"file_type":90,"home_preview_img_url":210,"slug":211,"view_count":98,"category_name":29,"create_tm":212},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=1796110919&Signature=PnVXVOor8erMLG5xbQ4iTpRvDvY%3D","1-tuples",1794018230,{"doc_id":214,"doc_title":215,"file_type":90,"home_preview_img_url":216,"slug":217,"view_count":86,"category_name":29,"create_tm":218},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=1796110919&Signature=uZ%2FusbCqhLcGDAS1IRX%2F3UZ5mF8%3D","chapter-2-lists-arrays-and-dictionaries",1794016092,{"doc_id":220,"doc_title":221,"file_type":90,"home_preview_img_url":222,"slug":223,"view_count":30,"category_name":29,"create_tm":224},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=1796110919&Signature=r9%2Bu%2FCKha%2BY7%2FXbwhy1NsweOzaI%3D","ocaml-introduction-tuples-and-lists",1794446560]