index(var)–error if abscent index(var, start, end)
remove(var)
pop() –returns, index optional
del list[index start : end]
max, min, sum,list.reverse(), sort() –for strings only sum will not work
map: ```python # input size of the list n = int(input(“Enter the size of list : “)) # store integrs in a list using map, # split and strip functions lst = list(map(int, input(“Enter the integer elements:”).strip().split()))[:n]
# printing the list print(‘The list is:’, lst)
```
Clear() Removes all items from the list
copy() Returns a copy of the list
Working:
Direct Address Table - problem Not handle large keys, floating point strings
Hash function- need to be fast, uniformly distribute large keys Examples
Advantages:
Best for Search, Insert, Delete in BigO(1)
insertion ovverides if exist already, no duplicates
DisAdvantages:
Strict search, yes or No.
No sorted order
Not handle large keys, floating point strings
Other functions
reduce() apply a particular function passed in its argument to all of the list elements stores the intermediate result and only returns the final summation value
sum() Sums up the numbers in the list
ord() Returns an integer representing the Unicode code point of the given Unicode character
cmp() This function returns 1 if the first list is “greater” than the second list
max() return maximum element of a given list
min() return minimum element of a given list
all() Returns true if all element is true or if the list is empty
any() return true if any element of the list is true. if the list is empty, return false
len() Returns length of the list or size of the list
enumerate() Returns enumerate object of the list
accumulate() apply a particular function passed in its argument to all of the list elements returns a list containing the intermediate results
filter() tests if each element of a list is true or not
map() returns a list of the results after applying the given function to each item of a given iterable
lambda() This function can have any number of arguments but only one expression, which is evaluated and returned.
Slicing
Negative steps to reverse list
gives different for list only. tuple gives same back…since immutable
Comprehensions
Sets
do not contain duplicates. {}
Sets
Dictionary
do not contain duplicates. {}
Comprehensions
list(li) to set, dictionay d1 = {x:x**3 for x in l1} d1 = {x:f”ID{x}” for x in l1} d1 = {l2[i]:l3[i] for i in range(len(l2))} or **## d3 = dict(zip(l2,l3)) **
reverse dictionary d2 = {v:k for (k,v) in d1.items()}
## A New Post for resources to learn Data Structures & Algorithms