QuestionDecember 14, 2025

35. What is a dictionary in Python and how is it different from a list? 36. Create a dictionary to store a person's name, age, and city.

35. What is a dictionary in Python and how is it different from a list? 36. Create a dictionary to store a person's name, age, and city.
35. What is a dictionary in Python and how is it different from a list?
36. Create a dictionary to store a person's name, age, and city.

Solution
4.4(301 votes)

Answer

{'name': 'Alice', 'age': 30, 'city': 'New York'} Explanation 1. Define a dictionary in Python A dictionary is an unordered, mutable collection of key-value pairs, defined with curly braces {}. 2. Difference between dictionary and list A list stores ordered elements accessed by index; a dictionary stores values accessed by unique keys. 3. Create a dictionary for person’s details Use curly braces and key-value pairs to store name, age, and city.

Explanation

1. Define a dictionary in Python<br /> A dictionary is an unordered, mutable collection of key-value pairs, defined with curly braces {}.<br />2. Difference between dictionary and list<br /> A list stores ordered elements accessed by index; a dictionary stores values accessed by unique keys.<br />3. Create a dictionary for person’s details<br /> Use curly braces and key-value pairs to store name, age, and city.
Click to rate:

Similar Questions