A developer wants to initialize a dictionary with a key of integers and values that are strings. Which initialization expression should be used?
A developer wants to initialize a dictionary with a key of integers and values that are strings. Which initialization expression should be used?
To initialize a dictionary with keys as integers and values as strings, use the format where each key-value pair is enclosed in curly braces, with the key being an integer and the value being a string. The correct form in this case is to have pairs like {3, 'three'} and {5, 'five'}. This ensures that the keys are integers and the values are strings, matching the desired dictionary type.
Tested in Studio !
Dictionaries are key-value pairs, meaning that the key is specified followed by the value. Thus, based on the question, the answer has to be an integer (number without quotes) followed by a string (anything surrounded by quotes), after that the next pair follows.
D should be the currect ans.