1/91
Looks like no tags are added yet.
List
A collection of similar data values.
Array
Another term for a list in programming.
GradeList
Example name for a list of grades.
Element Number
Index of an item in a list, starting at 0.
Subscript
Another term for element number in a list.
Creating a List
Assigning values to a variable using brackets.
List Syntax
Defined by brackets with comma-separated values.
Accessing Elements
Using the list name and index to retrieve values.
Modifying Elements
Changing a list element's value using its index.
Average Calculation
Sum of values divided by the count.
Input Function
Reads user input, often converted to int.
Grades Example
List of quiz grades: [87, 93, 75, 100, 82, 91, 85].
Variable Assignment
Storing data in a variable for later use.
List Element Assignment
Assigning a new value to a specific list index.
List Length
Total number of elements in a list.
Grades Modification
Changing values in the grades list example.
Print Function
Outputs the specified value to the console.
Integer Conversion
Converts input string to an integer.
Element Retrieval
Accessing a list item using its index.
List Naming Convention
Using descriptive names for better clarity.
Indexing
Referring to list elements by their position.
List Container
A structure to hold multiple data items.
grades
A list containing student grades.
grades[1]
Accesses the second element of the grades list.
grades[2] -= 90
Subtracts 90 from the third grade.
grades[3]
Accesses the fourth element of the grades list.
print(grades[3])
Outputs the value of grades[3].
len(x)
Returns the number of elements in list x.
Looping through a list
Accessing all elements using a loop.
mysum
Variable used to accumulate total grades.
average
Calculated mean of the grades list.
for i in range(7)
Loops through indices 0 to 6.
for i in grades
Iterates directly over elements in grades.
Changing a list in a loop
Attempting to modify list elements via loop variable.
grades[i] = 100
Directly modifies the i-th element of grades.
enumerate(grades)
Provides index and value during iteration.
range(x)
Generates a sequence from 0 to x-1.
append
Adds an element to the end of a list.
grades.append(95)
Adds 95 to the end of the grades list.
Initializing sum
Setting mysum to 0 before accumulation.
Accessing elements
Using indices to retrieve list values.
Looping with unknown size
Using len() to handle dynamic list sizes.
i takes the value
Variable i holds the current element's value.
mysum is increased
Accumulating total in mysum during iteration.
Changing values in a loop
Direct access needed to modify list elements.
List operations
Performing actions like adding or modifying elements.
Printing a list
Displays elements in square brackets, comma-separated.
Finding the length
Determining how many items are in a list.
concatenation
Combining two lists into a new list.
IndexError
Error when accessing an out-of-range index.
indexing
Accessing list elements using their position.
negative indexing
Accessing elements from the end of a list.
slicing
Extracting a subpart of a list.
list slicing syntax
Format: [a:b] for sublist.
step size
Specifies increment in list slicing.
sublist
A portion of the original list.
list adjustment
Modifying a list using slicing.
reversing a list
Using negative step size in slicing.
concatenating lists
Combining lists using += operator.
out-of-range slicing
Slicing beyond list limits returns valid sublist.
empty list
A list with no elements.
inserting values
Adding elements at a specific index.
string as list
Strings treated as lists of characters.
length of list
Number of elements in a list.
list memory location
Each list occupies a unique memory space.
slice without start
Starts from the beginning of the list.
slice without end
Continues to the end of the list.
slicing with default step
Default step size is 1 in slicing.
slicing examples
Demonstrates various slicing techniques.
list operations
Various methods to manipulate lists.
String Slicing
Extracting substring using index ranges.
TypeError
Error when invalid operations are attempted on types.
Slicing Lists
Extracting sublists using index ranges.
Lists of Lists
A list containing other lists as elements.
grid
Example of a list of lists structure.
len(A)
Returns the number of elements in list A.
max(A)
Returns the maximum value in list A.
min(A)
Returns the minimum value in list A.
sum(A)
Calculates the total of all elements in A.
A.append(B)
Adds element B to the end of list A.
A.insert(B, C)
Inserts C at index B in list A.
A.sort()
Sorts list A in ascending order.
A.index(B)
Finds the first occurrence of B in A.
A.pop(B)
Removes and returns element at index B.
A.remove(B)
Removes the first instance of value B.
String.split()
Divides a string into a list based on delimiters.
list()
Converts a string into a list of characters.
join()
Concatenates list elements into a single string.
Concatenation
Combining two lists into one.
Data Type Consistency
Lists ideally contain elements of the same type.
Whitespace Split
Divides string into words based on spaces.
Character Split
Divides string into individual characters.