Unlock the Power of Python Keywords and Functions!
Unlock the Power of Python Keywords and Functions!
08. Miscellaneous
1. del - Delete an object.
2. with - Context manager for resource management (e.g., file handling).
3. as - Alias for modules or within with statements.
4. print - Function for output (in Python 3.x, it's not a keyword but a
built-in function).
5. exec - Execute dynamically created Python code (rarely used in
Python 3).
super
Advanced super usage in multiple inheritances:
Types Of Python Keywords
Sorting:
1. sorted() - Returns a new sorted list without modifying the original.
2. .sort() - Sorts the list in-place (modifies the original).
3. sorted() with key - Sorts using a custom key.
4. Sort in descending order - Use reverse=True with sorted().
Reversing:
1. reversed() - Returns an iterator for reversing a list.
2. Slicing - Reverse a list using slicing.
Removing Duplicates:
1. set() - Removes duplicates but doesn't preserve order.
2. OrderedDict.fromkeys() - Removes duplicates while maintaining
order.
Merging:
1. Merge lists - Combine two lists using +.
2. Extend lists - Add elements of one list to another.
Was it Like
helpful? Comment
Chetan Shidling
@chetan_shidling_ Save
www.cselectricalandelectronics.com