1/17
Practice flashcards covering Python data structures including tuples, map/lambda, file handling, sets, 2D lists, dictionaries, and arrays based on the DSAL Quiz Review.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Tuples
Immutable data structures in Python that do not support item assignment; attempting to modify an element directly will raise a TypeError.
map() function
A function that applies a given function, often a lambda, to every item in one or more iterables; for example, applying "pre_ " to words using map(lambda\,w:\,\text{"pre_ "}\,+\,w,\,words).
File Closing
A mandatory practice in file handling that ensures any pending changes are saved and frees up system resources for other processes.
symmetric_difference()
A set method that returns a new set containing elements that are in either Set A or Set B, but excludes elements that are common to both.
popitem()
A dictionary method that removes and returns an arbitrary (key, value) pair from the dictionary.
Slice Assignment
A list operation, such as LstA[1:3]=[4,5,6], that replaces a range of elements and has the capability to change the total length of the list.
Array Type Consistency
A requirement of the Python array module where all elements must be of the same data type; adding a string to an integer array will raise a TypeError.
get() method
A dictionary method used to retrieve a value for a specific key, such as grades.get("David",0), which prevents an error if the key is missing from the dictionary.
File Mode "r+"
A file handling mode that allows the user to read existing content and update or write to the file without erasing the current contents.
File Mode "x"
An exclusive creation mode in file handling that allows the creation of a new file but raises an error if the file already exists.
Set Unique Storage
The property of sets to store only unique elements; adding a duplicate value through methods like add() or update() will not increase the set's length.
Row Retrieval in 2D Lists
The process of accessing a specific nested list within a matrix, such as using matrix[2] to retrieve the entire third row.
Element Retrieval in 2D Lists
Accessing a specific value within a matrix using double indexing, where matrix[1][1] identifies the element at the second row and second column.
Dictionary copy() method
A method that creates a shallow copy of a dictionary, ensuring that changes made to keys in the new copy, such as d2["x"]=10, do not affect the original dictionary.
Column Extraction
The use of list comprehension, such as column=[row[2]forrowinmatrix], to create a new list from a specific vertical index across all rows.
array.array('f', …)
A specialized data structure that stores numeric floating-point values and requires that any appended items also be of type float.
Tuple with Mutable Objects
A scenario where a tuple contains a list, such as (1,2,[3,4]); while the tuple itself is immutable, the inner list can still be modified using methods like append().
Reference vs. Copy Assignment
The distinction in list handling where lst2val=lstval creates a reference to the same object, while lst2val=lst2val+[5] creates a entirely new list object.