Q. Find the error/output. Consider below given two sets of codes. Which one will produce an error? Also, predict the output produced by the correct code.


(a)

box = {}

jars = {'Jam' : 4}

crates = {}

box['biscuit'] = 1

box['cake'] = 3

crates['box'] = box

crates['jars'] = jars

print (len(crates[box]))


(b)

box = {}

jars = {'Jam' : 4}

crates = {}

box['biscuit'] = 1

box['cake'] = 3

crates['box'] = box

crates['jars'] = jars

print (len(crates['box']))



Answer =

Output: -

(a) Error in line 8.

(b)

2
>>>

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. First a part is not correct
    Give the correct one

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post