dictionaries | SoloLearn: Learn to code for FREE!

0

dictionaries

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

9/22/2019 2:34:24 AM

saha vlaxmi

1 Answer

New Answer

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