VJC Chapter 4 Data Structures
Uploaded by cheesemuffin · 10 December 2025
Preview
VJC/H2Computing/9569 Chapter 4: Data Structures Contents 1 Lists 1.1 Create 1.2 Add list items 1.2.1 Append 1.2.2 Insert 1.2.3 Extend 1.2.4 Using operator 1.3 Read 1.4 Update 1.5 Delete 1.5.1 Remove item by value 1.5.2 Remove item by index 1.5.3 Del keyword 1.5.4 Clear a list 1.6 Working with List 1.6.1 Min, Max and Sum 1.6.2 Reversing 1.6.3 Sorting 1.6.4 Membership and searching 1.7 Copying List 1.7.1 By Slicing 1.7.2 By Constructor 1.7.3 The copy() method 1.8 List Comprehension 2 Tuples 2.1 Unpacking Tuples 3 Dictionaries 3.1 Create 3.2 Access 3.3 Update 3.4 Add 3.5 Delete Syllabus Learning Outcomes 2.2 Programming Elements and Constructs Use programming language elements and constructs to write recursive and non-recursive programs to solve a variety of problems. 2.2.1 Understand the different types: integer, real, char, string and Boolean and initialise arrays (1-dimensional and 2-dimensional). 1
VJC/H2Computing/9569 1 Lists Lists are the most commonly used data structure in Python. Lists are used to store multiple items in a single variable. List items are ordered, mutable and allow duplicate values. A list collection is mutable means its items can be added, updated and removed. Each of these data can be accessed by calling its index value. 1.1 Create Lists are created using square brackets. There are a few ways to initialise a list. List items can be of any data type. A list can also contain different data types. 2
VJC/H2Computing/9569 A list can also contain sublists, which is known as a nested list. 1.2 Add list items 1.2.1 Append The append( ) method is used to append an element at the end of the list. 1.2.2 Insert The insert() method inserts an item at the specified index. 1.2.3 Extend A list can also be extended with items from another list using extend() method. It will modify the first list. The resultant list will contain all the elements of the lists that were added, i.e. the resultant list is NOT a nested list. 3
VJC/H2Computing/9569 1.2.4 Using operator Two lists can also be join together simply using + operator. Similar to String, we can repeat a list multiple times with * operator. 1.3 Access list items List items are indexed and you can access them by referring to the index number. The first item has index 0. We can also access the elements in the list using negative indexing. That is the last element has an index of -1, and second last element has index of -2 and so o
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

