0
What is the result of this code? fib = {1: 1, 2: 1, 3: 2, 4: 3} print(fib.get(4, 0) + fib.get(7, 5))
What is the result of this code? with detail description...
1 Respuesta
+ 2
In get() you have two parameters
Actually the first one is the key and the second one is the value which is return when key is not present in the dictionary
get(key, value to return if key is not present)
fib.get(4,0)
in this key 4 is present in the dictionary therefore value from dictionary is returned i.e. 3
fib.get(7,5)
Key 7 is not present in the dictionary therefore 5 is returned
So the output will be 3+5. = 8