What will be the output of the following Python code?

ICSE Class 10 Robotics & AI PYQ · 2025 Paper · Section A

2(x)1 Mark · 2025 · Section A · 2025 Paper

What will be the output of the following Python code?

x = {1: 'apple', 2: 'banana'}
x[3] = "cherry"
print(x)
Show SolutionHide Solution↓
{1: 'apple', 2: 'banana', 3: 'cherry'}

In a Python dictionary, values are stored using keys. The statement x[3] = "cherry" means that the value "cherry" is assigned to the key 3. This adds a new key–value pair to the dictionary, which is then displayed when the dictionary is printed.

← Previous questionNext question →

Browse the free Robotics & AI sample bank