Question 13
Evaluate:
Hint
The .get() method takes in 1 or 2 parameters:
- (compulsory) Value contained in the dictionary by the given value as the hashed key
- (optional) Returned value should the value at key (first value) does not exist
Solution
{2: 4, 3: 9, 5: 25} does not have a key 4, hence there is no value to be retrieved.
However, since we defined a value to be returned in this kind of scenario here, it returns 0.