PCAP Practice Test

PCAP Practice Test practice questions, page 4 of 6, with answer review and explanations.

Question 16

What is the expected output of the following snippet?

  1. 1
  2. 4
  3. 2
  4. 3

Question 17

What is the expected output of the following snippet?

  1. abc
  2. The code will cause a runtime exception
  3. ABC
  4. 123

Question 18

How many elements will the list2 list contain after execution of the following snippet?

  1. zero
  2. five
  3. seven
  4. three

Question 19

What would you used instead of XXX if you want to check weather a certain 'key' exists in a dictionary called dict? (Choose two.)

  1. 'key' in dict
  2. dict ['key'] != None
  3. dict.exists ('key')
  4. 'key' in dict.keys ( )

Question 20

You need data which can act as a simple telephone directory. You can obtain it with the following clauses (Choose two.) (assume that no other items have been created before)

  1. dir={'Mom': 5551234567, 'Dad': 5557654321}
  2. dir= {'Mom': '5551234567', 'Dad': '5557654321'}
  3. dir= {Mom: 5551234567, Dad: 5557654321}
  4. dir= {Mom: '5551234567', Dad: '5557654321'}