[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-685629-105":59,"doc-detail-685629-en":130,"doc-similar-685629":148},{"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","chapter-2-lists-arrays-and-dictionaries","Chapter 2: Lists, Arrays and Dictionaries","","Chapter 2 explains higher-order data structures in Python, focusing on how to manage collections beyond scalar variables. It introduces tuples as immutable comma-separated values and demonstrates element access using zero-based indexing and slicing ranges. It then presents lists as mutable bracket-enclosed collections, including the use of Python range objects to generate sequences. Finally, it describes arrays as named storage for lists/tuples, covering assignment and index-based element retrieval using drawer-style indices.",{"@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/chapter-2-lists-arrays-and-dictionaries/685629/",{"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/chapter-2-lists-arrays-and-dictionaries/685629.png","ImageObject",300,407,{"name":92,"@type":93},"4398046744996","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-30","2026-11-07",true,{"@type":102,"interactionType":103,"userInteractionCount":29},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"Why do scalar variables become insufficient in Python programs?","Question",{"text":112,"@type":113},"Scalar variables only represent single values like numbers or strings. Complex data tasks (e.g., large biological datasets) require managing many related items, which motivates lists, tuples, and dictionaries.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do you access elements in a Python tuple?",{"text":117,"@type":113},"Place the desired index (or indexes) in square brackets after the tuple. Indexing starts at 0, so the second element uses index 1.",{"name":119,"@type":110,"acceptedAnswer":120},"What is the difference between Python tuples and lists?",{"text":121,"@type":113},"Tuples are immutable, meaning their contents cannot be changed after creation. Lists are mutable, so they can be modified after creation.","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},685629,1794016092,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":66,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":29,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":52,"language":138,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":67,"update_tm":129,"read_time":142,"preview_page_count":8,"preview_urls":143},4398046744996,"# Chapter 2: Lists, Arrays and Dictionaries\n\n## 1. Higher order organization of data\n\nIn the previous chapter, we have seen the concept of scalar variables that define memory space inwhich we store a scalar, i.e. single numbers or strings. Scalar values however are usuallyinsufficient to deal with current data. Imagine writing a program that analyzes the whole humangenome. Since it contains approx. 30,000 genes, we would have to create 30,000 variables tostore their sequences! Initializing these variables would already be a daunting task, but imaginethat you wanted to count the number of times the sequence ATG appears in each gene, youwould have to write one line of code for each gene, hence 30,000 lines, changing only thevariable name for the gene!  \nFortunately, Python thinks that laziness is a virtue, and would never tolerate that you have towrite 30,000 lines of code. Two special types of variables exist to help managing long lists ofitems, namely arrays and dictionaries. These variables store lists of data, and each piece of datais referred to as an element. In this chapter, we will look in details at what are lists, and howthey are stored and manipulated within arrays and dictionaries.  \nWe are all familiar with lists: think about a shopping list, a soccer team roster, all integersbetween 1 and 10, genes in the human genomes,…A list can be ordered (increasing or decreasingvalues for numbers, lexicographic order for strings), or unordered. Python has two types of lists,tuples and lists. Tuples are immutable, i.e. they cannot be modified once created, while lists aremutable, i.e. they can be modified once created.  \n## 2. Tuples\n\n### 2.1 Tuples in Python\n\nBy definition, a tuple is a set of comma-separated values enclosed in parentheses.  \nExamples:  \n- (1,2,3,4,5,6,7,8,9,10) is the tuple of integers between 1 and 10  \n- (‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’,’Sunday’) is thetuple containing the days in the week.  \n### 2.2 Accessing tuple values\n\nWe have seen how to build a tuple. Another thing that is useful is to be able to access a specificelement or set of elements from a tuple. The way to do this is to place the number or numbers ofthe element (s) we want in square brackets after the tuple. Let us look at an example:  \n>>> print (‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’,’Sunday’)[2]  \nWhich day do you think will be printed? If you try it, you will get:  \n‘Wednesday’  \nWhy didn’t we get “Tuesday”, the second element of the list? This is because Python startscounting from 0 and not 1!! This is something important to remember.  \nThe element you want does not have to be literal: it can be a variable as well. As an exercise,write a small program that reads in a number between 1 and 7, and outputs the corresponding dayof the week. The answer is on the next page.  \n>>> \\# Read in day considered>>> day=int(raw_input(“Enter a number from 1 to 7 : “))>>> \\#  \n>>> \\# print element ‘day’of the list of days of the week:  \n>>> \\#  \n>>> print (‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’,’Sunday’)[day]  \nThe examples above show you how to single out one element of a tuple; if you wanted more thanone element, you can “splice” the tuple, the same way we splice strings. For example,  \n>>>print (‘Monday’,’Tuesday’,’Wednesday’,’Thursday’,’Friday’,’Saturday’,’Sunday’)[0:2]  \nwill print  \n(‘Monday’,’Tuesday’)  \nRemember that the range i:j means from position i to position j, j not included.  \n## 3. Lists\n\nA list in Python is created by enclosing its elements in brackets:  \n>>> [“Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”,”Sunday”]  \nElements in a list are accessed the same way elements are accessed in tuples.  \nSpecial lists: ranges  \nOften the lists we use have a simple structure: the numbers from 0 to 9, or the numbers from 10to 20. We do not need to write these lists explicitly: Python has the option to specify a range ofnumbers. The two examples cited would ","cbCailnaxZgjeO3R","https://ap.wps.com/l/cbCailnaxZgjeO3R","pdf",207104,"English","# 1. Higher order organization of data\n# 2. Tuples\n## 2.1 Tuples in Python\n## 2.2 Accessing tuple values\n# 3. Lists\n# 4. Arrays\n## 4.1 Assigning arrays\n## 4.2 Accessing one element in an array","[{\"question\":\"Why do scalar variables become insufficient in Python programs?\",\"answer\":\"Scalar variables only represent single values like numbers or strings. Complex data tasks (e.g., large biological datasets) require managing many related items, which motivates lists, tuples, and dictionaries.\"},{\"question\":\"How do you access elements in a Python tuple?\",\"answer\":\"Place the desired index (or indexes) in square brackets after the tuple. Indexing starts at 0, so the second element uses index 1.\"},{\"question\":\"What is the difference between Python tuples and lists?\",\"answer\":\"Tuples are immutable, meaning their contents cannot be changed after creation. Lists are mutable, so they can be modified after creation.\"}]","Chapter 2: Lists, Arrays and Dictionaries | PDF",25,[144],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/aaa298f62bda401cb49911787ba4eb45.webp",983,1272,{"list":149,"token":66},[150,156,162,168,174,180,186,192,198,204],{"doc_id":151,"doc_title":152,"file_type":136,"home_preview_img_url":153,"slug":154,"view_count":34,"category_name":30,"create_tm":155},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=1796110619&Signature=DxT%2BRQ2AkBVY2MG1mg6Yg287zuo%3D","60001-lecture-5-tuples-lists-aliasing-mutability-cloning",1794446554,{"doc_id":157,"doc_title":158,"file_type":136,"home_preview_img_url":159,"slug":160,"view_count":29,"category_name":30,"create_tm":161},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=1796110619&Signature=6KuyzfaYVjygh3byiRWP80nKTSo%3D","lecture-4-tuples-list-slicing-list-comprehension-strings",1794446559,{"doc_id":163,"doc_title":164,"file_type":136,"home_preview_img_url":165,"slug":166,"view_count":24,"category_name":30,"create_tm":167},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=1796110619&Signature=9FqZqpfc9uVq9j9RxLulNnKdR%2BI%3D","topic-6-lists-sets-tuples-dictionaries",1794018231,{"doc_id":169,"doc_title":170,"file_type":136,"home_preview_img_url":171,"slug":172,"view_count":19,"category_name":30,"create_tm":173},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=1796110619&Signature=K%2F0%2B7dsteUr24yOWn%2FmZUwTLm9Y%3D","tuple-in-python-lecture-2",1794018232,{"doc_id":175,"doc_title":176,"file_type":136,"home_preview_img_url":177,"slug":178,"view_count":81,"category_name":30,"create_tm":179},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=1796110619&Signature=1WBn%2FhVveLbqX1cB2OKOinFEOD8%3D","unit-iv-list-tuples-dictionaries-problem-solving-and-python-programming",1794018219,{"doc_id":181,"doc_title":182,"file_type":136,"home_preview_img_url":183,"slug":184,"view_count":19,"category_name":30,"create_tm":185},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=1796110619&Signature=GCkNH9dMJQl%2FOhX8XoET3nK2rno%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":187,"doc_title":188,"file_type":136,"home_preview_img_url":189,"slug":190,"view_count":34,"category_name":30,"create_tm":191},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=1796110619&Signature=MMxjWWi1zG%2BjFNtdsVSs7t9CIkM%3D","python-3-cheat-sheet-concise-reference",1793572698,{"doc_id":193,"doc_title":194,"file_type":136,"home_preview_img_url":195,"slug":196,"view_count":81,"category_name":30,"create_tm":197},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=1796110619&Signature=quE8qT%2BgGH92M5cz50AL6ecUpqM%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":199,"doc_title":200,"file_type":136,"home_preview_img_url":201,"slug":202,"view_count":34,"category_name":30,"create_tm":203},685788,"Python Arrays - Learn How to Create, Access, and Modify Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999694760/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796110619&Signature=Y6se2Azs5deurh6COELZvQ0nzy0%3D","python-arrays-learn-how-to-create-access-and-modify-lists",1794018478,{"doc_id":205,"doc_title":206,"file_type":136,"home_preview_img_url":207,"slug":208,"view_count":34,"category_name":30,"create_tm":179},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=1796110619&Signature=17YUnLeiBDkcSXcCj6K1o6AFILA%3D","lists-and-tuples-chapter-7-programming-concepts"]