


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document introduces the concepts of arrays and lists in programming. Arrays and lists are data structures used to store collections of data. They allow you to group multiple values of the same or different data types into a single container. Lists are a common data structure in many programming languages, including Python. the key characteristics of lists, such as being homogeneous or heterogeneous, ordered, mutable, and dynamic in size. It also provides examples of creating and accessing elements in a list, as well as common list operations like adding and removing elements.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Introduction
Creating Lists In Python, lists are created by enclosing elements in square brackets []. Example:
fruits = ["apple", "banana", "cherry"] Accessing Elements
first_fruit = fruits[0] Accesses the first element ("apple") Common List Operations Adding Elements fruits.remove("banana") Removes the first "banana" found. fruits.sort() Sorts the list in alphabetical order.
List Slicing - You can extract a portion (slice) of a list using slicing notation. Example: ```python subset = fruits[1:3] Extracts elements at index 1 and 2 ("banana" and "cherry") Nested Lists matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Summary: