Exam UiARD All QuestionsBrowse all questions from this exam
Question 130

A developer wants to initialize a dictionary with a key of integers and values that are strings. Which initialization expression should be used?

    Correct Answer: B

    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.

Discussion
Engineer24Option: B

Tested in Studio !

Herman62639Option: B

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.

sur_bhi123456789Option: D

D should be the currect ans.