Consider the following Python code:
Which ONE of the following is the output of this code?
python
- A6
- B1
- C8
- D9
Programming, Data Structures and AlgorithmsProgramming in PythonMCQ2 marks · −2/3 if wrongEasy
1def count(child_dict, i):
2 if i not in child_dict.keys():
3 return 1
4 ans = 1
5 for j in child_dict[i]:
6 ans += count(child_dict, j)
7 return ans
8
9child_dict = dict()
10child_dict[0] = [1,2]
11child_dict[1] = [3,4,5]
12child_dict[2] = [6,7,8]
13print(count(child_dict,0))
14A GATE question every morning
One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.