nerdexam
Python_Institute

PCAP-31-03 · Question #72

What would you use instead of XXX if you want to check whether a certain ` key' exists in a dictionary called diet? (Select two answers)

The correct answer is A. 'key' in diet D. 'key' in diet.keys(). See the full explanation below for the reasoning.

Question

What would you use instead of XXX if you want to check whether a certain ` key' exists in a dictionary called diet? (Select two answers)

Options

  • A'key' in diet
  • Bdiet['key'] != None
  • Cdiet.exists('key')
  • D'key' in diet.keys()

How the community answered

(66 responses)
  • A
    80% (53)
  • B
    6% (4)
  • C
    14% (9)

Community Discussion

No community discussion yet for this question.

Full PCAP-31-03 Practice