ord(char) - ord('a')
>>> ord('a') = 97
>>> ord('A') = 65
>>> ord('z') = 97+25 = 122 # total 26 letters calculations
>>> ord('Z') = 65+25 = 90 # total 26 letters calculations
array = [1, 1, 1, 3]
array.count(1) # 3
array.find(1) # 0
array.rfind(1) # 2
array.find(2) # -1 d ={}
d.get('cat', 0) # 0 - setting default if key doesn't existfrom collections import defaultdict
d = defaultdict(int) # (dict, but if key doesn't exist then create one with some default value)
d['cat'] # 0val in set1 # O(1) operation
set([1,2]) - set([1]) = set([2]) # substraction
[set()] * 9 ## DON'T DO THIS - all 9 will be ref to same set objectordered + immutable collection of items
dict[tuple(1,2,3)] = 2 # hashable: can be used as dict keyfloat('inf')
float('-inf')import math
math.ceil(2.2) # 3
math.floor(2.8) # 2defaultdict(dict, but if key doesn't exist then create one with some default value)dequeu(push and pop from both ends with O(1))Counter(makes counter dict of the iterrable)
sorted- O(n log n) worst, O(n) best