Python Institute PCAP Exam Practice Questions (P. 4)
- Full Access (141 questions)
- One Year of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #16
What is the expected output of the following snippet?


send
light_mode
delete
Question #17
What is the expected output of the following snippet?


send
light_mode
delete
Question #18
How many elements will the list2 list contain after execution of the following snippet?


send
light_mode
delete
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.)


- A'key' in dictMost Voted
- Bdict ['key'] != None
- Cdict.exists ('key')
- D'key' in dict.keys ( )Most Voted
Correct Answer:
BD
Reference:
https://thispointer.com/python-how-to-check-if-a-key-exists-in-dictionary/
BD
Reference:
https://thispointer.com/python-how-to-check-if-a-key-exists-in-dictionary/
send
light_mode
delete
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)
- Adir={'Mom': 5551234567, 'Dad': 5557654321}Most Voted
- Bdir= {'Mom': '5551234567', 'Dad': '5557654321'}Most Voted
- Cdir= {Mom: 5551234567, Dad: 5557654321}
- Ddir= {Mom: '5551234567', Dad: '5557654321'}
Correct Answer:
CD
CD
GPT-4o - Answer
Hey there! When setting up dictionaries in Python, if you want to use strings as keys, you need to put them in quotes. Options C and D used unquoted words like Mom and Dad, suggesting they might be variables or identifiers - which could be true if they’re defined elsewhere, but not under normal circumstances without prior setup mentioned. That said, if Mom and Dad were predefined variables or constants, options C and D can work correctly. But since the usual use involves strings directly as keys, sans any prior definitions, A and B are technically more reliable choices without additional context. Trust what works straight out of the box!
send
light_mode
delete
All Pages
