Skills101
← All practice quizzes

Quiz: Python Dictionaries

5 questionsNo time limitPass: 60%+10 XP on first pass

Store data by name instead of position. Create, read, update and loop over dictionaries, use get() safely, count things, and nest dictionaries for JSON-like data.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    d = {"a": 1, "b": 2}
    d["a"] = 5
    print(d["a"] + d["b"])
    
  2. Question 2

    What does {"x": 1}.get("y", 0) return?

  3. Question 3

    Which CANNOT be a dictionary key?

  4. Question 4

    What does this print?

    d = {}
    for ch in "aab":
        d[ch] = d.get(ch, 0) + 1
    print(d)
    
  5. Question 5

    What does len({"a": 1, "a": 2}) return?