Python - Part I
Python - Part I
NOTE - PART I
Tuples in Python
❖ A tuple in Python is the representation of a record data structure we discussed in Topic 01.
❖ We can store a collection of items as a tuples in Python.
❖ Those items can be of multiple types.
o Syntax:
o Examples:
❖ Following illustration shows how Python tuple items are saved in main memory.
▪ Examples:
➢ However, if you try to access an index number that do not exist in the specified tuple,
following error will occur:
▪ Examples:
➢ However, if you try to access an index number that do not exist in the specified tuple, there
will not be an error:
Lists in Python
❖ A list in Python is the representation of array data structure we discussed in Topic 01.
❖ We can store a collection of items as a list in Python, just like in tuples.
❖ Those items can be of multiple types, just like in tuples.
o Syntax:
o Examples:
❖ Following illustration shows how Python tuple items are saved in main memory.
▪ Examples:
➢ However, if you try to access an index number that do not exist in the specified list,
following error will occur:
▪ Examples:
➢ However, if you try to access an index number that do not exist in the specified tuple, there
will not be an error: