Q. Predict the output:


(a)

fruit = {}

L1 = ['Apple', 'banana', 'apple']

for index in L1 :

    if index in fruit :

        fruit [index] += 1

    else :

        fruit [index] = 1

print (len(fruit))

print (fruit)


(b)

arr = {}

arr [1] = 1

arr ['1'] = 2

arr[1] += 1

sum = 0

for k in arr :

    sum += arr[1]

print (sum)



Answer =

Output: -

(a)

3
{'Apple': 1, 'banana': 1, 'apple': 1}
>>>

(b)

4
>>>

7 Comments

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

Post a Comment

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

Previous Post Next Post