Advance Python Programming - Unit 1 Notes
1.1 Use of String and List operations in Python Programs
String:
- A string is a sequence of characters enclosed in quotes.
- Strings are immutable.
- Common methods: upper(), lower(), replace(), strip(), split(), find()
List:
- A list is an ordered, mutable collection of items.
- Lists can contain elements of different types.
- Common methods: append(), insert(), remove(), pop(), sort(), reverse(), count(), index()
1.2 Use built-in functions for Set manipulation
Set:
- A set is an unordered collection of unique items.
- Sets are mutable but cannot contain mutable items like lists.
- Common methods: add(), remove(), discard(), pop(), clear(), update()
- Set operations: union(), intersection(), difference(), symmetric_difference()
1.3 Use of Tuple operations in Python programs
Tuple:
- A tuple is an ordered, immutable collection of items.
- Tuples are defined using parentheses ().
- Access using index and slicing.
- Common methods: count(), index()
- Tuples can be iterated using loops.
Advance Python Programming - Unit 1 Notes
1.4 Use built-in functions for Dictionary manipulation
Dictionary:
- A dictionary stores data in key-value pairs.
- Keys must be unique and immutable.
- Dictionaries are mutable.
- Common methods: keys(), values(), items(), get(), pop(), update(), clear()
- Access items using key: my_dict['key']
- Add/Update: my_dict['new_key'] = value