Important (Python Built-In Methods) (CheatSheet)
Important (Python Built-In Methods) (CheatSheet)
1. String Methods
● strip(): Removes whitespaces from the start and end. s = ' hello
'.strip()
2. List Methods
3. Dictionary Methods
4. Set Methods
6. General Purpose
7. Conversion Functions
● int(): Converts to an integer. i = int('123')
● float(): Converts to a float. f = float('123.45')
● str(): Converts to a string. s = str(123)
● list(): Converts to a list. lst = list('abc')
● dict(): Converts to a dictionary. dct = dict([(1, 'one'), (2, 'two')])
● set(): Converts to a set. st = set([1, 2, 3])
● tuple(): Converts to a tuple. t = tuple([1, 2, 3])
8. Mathematical Functions
12. Miscellaneous
● globals(): Returns the global symbol table. global_symbols = globals()
● locals(): Returns the local symbol table. local_symbols = locals()
● callable(): Checks if an object is callable. is_callable = callable(obj)
● eval(): Evaluates a Python expression. result = eval('1 + 2')
● exec(): Executes Python code dynamically. exec('print(42)')
18. Comprehensions
20. Serialization