Exam-style question
Try this first
Which Python dictionary represents the function that maps 0 to 2.0, 1 to 3.14159, 2 to -1.0 and 3 to 2.718281828?.
- A.{0: 2.0, 1: 3.14159, 2: -1.0, 3: 2.718281828}
- B.{2.0: 0, 3.14159: 1, -1.0: 2, 2.718281828: 3}
- C.{0: 1, 1: 2, 2: 3, 3: 4}
- D.[0: 2.0, 1: 3.14159, 2: -1.0, 3: 2.718281828]
Model answer
What a good answer should say
- {0: 2.0, 1: 3.14159, 2: -1.0, 3: 2.718281828}
Explanation
Why this works
In the function interpretation, each index is mapped to the corresponding real-number entry. A Python dictionary stores each index as a key and its vector value as the associated value.
Common mistake
No common mistake is linked to this question yet.
