- 2

dictionaries

fib = {1: 1, 2: 1, 3: 2, 4: 3} print(fib.get(4, 0) + fib.get(7, 5)) Explain this code

22nd Sep 2019, 2:34 AM
veeralakshmi.v
veeralakshmi.v - avatar
1 Respuesta
0
In this code fib.get(4,0) gives you value 3 because you need value of key 4 but you put 0 so it mark 0 as null so it gives you back value of 4th key ie 3 And fib.get(7,5) gives you 5 because there is no such key with value 7 so it give back you 5 as result Whole fib.get(4,0)+fib.get(7,5) gives you answer 8
22nd Sep 2019, 2:51 AM
Chirag Kumar
Chirag Kumar - avatar