Question:

Consider the following Python code :
def count (child_dict, i) :
if i not in child_dict.keys() :
return 1
ans = 1
for j in child_dict[i] :
ans += count (child_dict, j)
return ans
child_dict = dict()
child_dict [0] = [1, 2]
child_dict [1] = [3, 4, 5]
child_dict [2] = [6, 7, 8]
print (count(child_dict,0))
Which ONE of the following is the output of this code ?

Updated On: Jul 9, 2024
  • 6
  • 1
  • 8
  • 9
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The correct option is (D) : 9.
Was this answer helpful?
0
0

Questions Asked in GATE AR exam

View More Questions