Sequences in Python
In Python, sequences are ordered collections of items, where each item is accessible by its position (index) in the collection. Sequences support various operations including indexing, slicing, and iteration. The most common sequence types in Python are: Lists are the most versatile sequence type. The elements of a list can be any object, and lists are mutable ordered sequence of items - they can be changed. Elements can be reassigned or removed, and new elements can be inserted. Tuples are like lists, but they are immutable ordered sequence of items - they can't be changed. Strings are a special type of sequence that can only store characters, and they are immutable. Sequence Operations Indexing Accessing an element by its position. Example: my_list = [10, 20, 30, 40, 50] printtems(my_list[0]) # Output: 10 print(my_list[-1]) # Output: 50 (last element) Slicing Accessing a sub sequence by specifying a start and end index. my_list = [10, 20, 30, 40, 50] print(my_list[1:4])...