TN Online TestSamacheer Kalvi practice

Lists, Tuples, Sets and Dictionary - Formula Sheet

Share this chapter: Telegram

Formula Sheet

This formula sheet lists key methods, operators, and functions used when working with Lists, Tuples, Sets, and Dictionaries in Python, along with their parameters and descriptions.

CategorySyntax / MethodDescription and Symbol Definitions
Listslist_var = [e1, e2, ...]Creates a mutable, ordered sequence where e1, e2 are elements of any data type.
Listslist_var.append(x)Appends element x to the end of the list.
Listslist_var.extend([x1, x2, ...])Appends multiple elements x1, x2, ... from an iterable to the end of the list.
Listslist_var.insert(i, x)Inserts element x at the specified index position i.
Listslist_var.remove(x)Removes the first occurrence of the element value x from the list.
Listslist_var.pop(i)Removes and returns the element at the index i. If i is omitted, removes the last element.
Listslist_var.clear()Deletes all elements from the list, leaving it empty.
Lists / Tupleslen(seq)Returns the total number of elements in the sequence seq.
Lists / Tuplesseq[start:stop:step]Slices the sequence from index start up to but not including index stop, moving forward by step.
Tuplestup_var = (e1, e2, ...)Creates an immutable, ordered sequence where e1, e2 are elements.
Tuplessingleton = (x,)Creates a tuple containing a single element x. The trailing comma is mandatory.
Setsset_var = {e1, e2, ...}Creates an unordered collection of unique elements where e1, e2 are unique items.
Setsset_A | set_BUnion: Returns a set containing all unique elements from set_A and set_B. Alternatively, use set_A.union(set_B).
Setsset_A & set_BIntersection: Returns a set containing elements common to both set_A and set_B. Alternatively, use set_A.intersection(set_B).
Setsset_A - set_BDifference: Returns a set containing elements that are in set_A but not in set_B. Alternatively, use set_A.difference(set_B).
Setsset_A ^ set_BSymmetric Difference: Returns a set containing elements in either set_A or set_B, but not both. Alternatively, use set_A.symmetric_difference(set_B).
Dictionariesdict_var = {k1: v1, k2: v2, ...}Creates an associative key-value mapping where k1, k2 are unique keys, and v1, v2 are their respective values.
Dictionariesdict_var[key] = valueAdds or updates the key with the specified value in the dictionary.
Dictionariesdel dict_var[key]Deletes the key-value pair corresponding to key from the dictionary.
Dictionariesdict_var.clear()Deletes all key-value pairs from the dictionary.
Solved MCQs → Practice test →

More for this chapter

Book Back Questions12 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python -Variables and Operators 6 Control Structures 7 Python functions 8 Strings and String manipulation 10 Python Classes and objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart