QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 92

Given data = dict(a=1), which exception type results from data["b"]?

  1. IndexError
  2. NameError
  3. AttributeError
  4. KeyErrorՃիշտ պատասխան

Բացատրություն

Dictionary subscription requests b, which is absent, so the mapping raises KeyError. IndexError belongs to out-of-range sequence positions, while a dictionary get call could instead provide a default without raising.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 92: Given data = dict(a=1), which exception type results from… · Python Fundamentals · Questena