Week 3 Unit 4: Self-test

Last updated: (05. April 2024)

Question 1

What is the purpose of a safe dictionary access?

Note: There are 3 correct answers to this question.


Safe dictionary access reduces the probability of being infected by a virus.❌
Safe dictionary access prevents access to keys, that do not exist.✅
Safe dictionary access limits the probability of wrong user input.❌
Safe dictionary access hides the actual access behind a condition, which checks the existence of the key.✅
Safe dictionary access should be used if it is not clear which keys are used to access a dictionary, for example, if the key is taken by user input.✅

Question 2

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



key does not exist❌
123❌
123 : "Harry"❌
"Harry"✅

< Previous unit | Next unit > | Course Overview