Question 18
The following Python expression is entered into a fresh Python shell with no prior import statements. Determine the result from evaluating the following expression. [3 marks]
Solution
Let's look at the tuple we are trying to get the length of here:
The elements in the tuple are as follows: (1, 2), 3, (4, 5), (6,).
Elements (1, 2) and (4, 5) count as 1 element each, since on the same surface level, these tuples are 1 unit.
In other words, we do not deep dive into each atomic element inside this whole tuple.
This then means that there are 4 elements in total, hence the given expression results as 4.