Draw This - beginner
Draw a diagram to represent a dictionary that stores the names of three fruits as keys and their colors as values. Use the following data: Apple - Red, Banana - Yellow, Grape - Purple.
Jump into concepts and practice - no test required
Draw a diagram to represent a dictionary that stores the names of three fruits as keys and their colors as values. Use the following data: Apple - Red, Banana - Yellow, Grape - Purple.
+---------+ +-------+ | Apple | ----> | Red | +---------+ +-------+ +----------+ +---------+ | Banana | ----> | Yellow | +----------+ +---------+ +---------+ +---------+ | Grape | ----> | Purple | +---------+ +---------+
This diagram shows a dictionary with three key-value pairs. Each key (fruit name) is inside a box on the left. An arrow points from each key to its value (color) on the right. This visually represents how a dictionary stores data: each key is linked to a specific value.
For example, the key "Apple" points to the value "Red", meaning the color of an apple is red. Similarly, "Banana" points to "Yellow", and "Grape" points to "Purple".
{'name': 'Alice', 'age': 30} uses correct syntax with colons and curly braces; others use wrong symbols or brackets.person = {'name': 'Bob', 'age': 25}
print(person['age'])person['age'] retrieves the value linked to key 'age'.print(person['age']) outputs 25.data = {'x': 10, 'y': 20, 'x': 30}
print(data['x'])data['x'] shows 30, the last assigned value, overwriting 10.students = [('Anna', 85), ('Ben', 92), ('Cara', 85), ('Dan', 92)]{name: score for name, score in students} correctly maps name: score. {score: name for name, score in students} reverses keys and values, causing score keys to overwrite. Options C and D add conditions changing values or keys incorrectly.