Week 3 Unit 3: Self-test

18. June 2024

Question 1

Which of the following statements about lists, tuples, and dictionaries are correct?

Note: There are 3 correct answers to this question.


If there are many attributes to describe a complex object and these attributes vary from object to object (in other words, each object has slightly different attributes), then tuples are a good choice.
If you have data about students and each data set for a student is structured in the same way (e.g. name, firstname, e-mail), then a list of tuples can be used to handle this data.
A dictionary should be chosen if there is a natural key like a student-ID or a unique number.
The data type for complex data should be carefully chosen, as this decision has an impact on the implementation of the program.
Tuples of lists is an often used pattern in programming.

Question 2

What is the value of variable a after the following statements have been executed?

week3 unit3 f2

Harry
Hermione
Key error
Index error

< Previous unit | Next unit > | Course Overview