Tuples Dictionaries

    1 / 50

    What does d.popitem() do in Python 3.7+?

    2 / 50

    Which method returns a value for a key, and if the key is not found, inserts it with a default value?

    3 / 50

    What is the result of d = {1: ‘A’}; del d[1]; print(d)?

    4 / 50

    How do you get the number of items in a dictionary?

    5 / 50

    Which of these can be a dictionary key?

    6 / 50

    What is the output of type({})?

    7 / 50

    What does d.update({‘c’: 3}) do?

    8 / 50

    What is a dictionary comprehension?

    9 / 50

    Are dictionaries ordered in Python 3.7+?

    10 / 50

    What is the output of dict([(‘a’, 1), (‘b’, 2)])?

    11 / 50

    How do you check if key ‘k’ exists in dictionary ‘d’?

    12 / 50

    Which method returns all the values in a dictionary?

    13 / 50

    What happens if you add a duplicate key to a dictionary?

    14 / 50

    How do you remove a key ‘k’ and return its value?

    15 / 50

    Which method returns all key-value pairs as tuples?

    16 / 50

    What is the result of len({‘a’: 1, ‘b’: 2})?

    17 / 50

    Which method removes all elements from a dictionary?

    18 / 50

    How do you add a new key ‘k’ with value ‘v’ to dictionary ‘d’?

    19 / 50

    What does d.get(‘x’, 0) return if ‘x’ is not in d?

    20 / 50

    Which method returns all keys in a dictionary?

    21 / 50

    Dictionary keys must be ___.

    22 / 50

    What is the output of d = {‘a’: 1}; print(d[‘a’])?

    23 / 50

    Which brackets are used for dictionaries?

    24 / 50

    Dictionaries store data in ___ pairs.

    25 / 50

    How do you create an empty dictionary?

    26 / 50

    What is the time complexity of accessing an element in a tuple by index?

    27 / 50

    Which function converts a list to a tuple?

    28 / 50

    What happens if you try T[0] = 5 on T = (1, 2)?

    29 / 50

    Can a tuple contain a list?

    30 / 50

    What is the output of 5 in (1, 5, 10)?

    31 / 50

    Is (1, 2, 3) the same as 1, 2, 3?

    32 / 50

    What does ‘a, b = 1, 2’ create?

    33 / 50

    Which function returns the largest element in a tuple?

    34 / 50

    What is the result of tuple(‘hi’)?

    35 / 50

    How do you delete a whole tuple ‘T’?

    36 / 50

    What is the output of a = (1, 2); b = a; print(a is b)?

    37 / 50

    Can you change an element inside a tuple after creation?

    38 / 50

    What is the output of (1, 2, 3)[1:3]?

    39 / 50

    Which method finds the first index of a value in a tuple?

    40 / 50

    What is the result of (1, 2) * 2?

    41 / 50

    What is tuple unpacking?

    42 / 50

    Can a tuple be used as a dictionary key?

    43 / 50

    What is the output of len((10, 20, 30))?

    44 / 50

    Which method returns the number of times a value appears in a tuple?

    45 / 50

    What is the result of (1, 2) + (3, 4)?

    46 / 50

    How do you access the first element of tuple T?

    47 / 50

    What is the output of print(type((1, 2)))?

    48 / 50

    Which brackets are used to define a tuple?

    49 / 50

    Tuples are mutable.

    50 / 50

    How do you create a tuple with one element?

    Your score is

    The average score is 8%

    Scroll to Top