Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCAP All Questions

View all questions & answers for the PCAP exam

Exam PCAP topic 1 question 20 discussion

Actual exam question from Python Institute's PCAP
Question #: 20
Topic #: 1
[All PCAP Questions]

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)

  • A. dir={'Mom': 5551234567, 'Dad': 5557654321}
  • B. dir= {'Mom': '5551234567', 'Dad': '5557654321'}
  • C. dir= {Mom: 5551234567, Dad: 5557654321}
  • D. dir= {Mom: '5551234567', Dad: '5557654321'}
Show Suggested Answer Hide Answer
Suggested Answer: AB 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
technoguy
Highly Voted 2 years, 12 months ago
Selected Answer: AB
option c d has key without quote. so it is not correct key
upvoted 11 times
...
JeyTlenJey
Most Recent 3 months, 4 weeks ago
Selected Answer: AB
Correct: A,B print("A.",{'Mom': 5551234567, 'Dad': 5557654321}) print("B.", {'Mom': '5551234567', 'Dad': '5557654321'}) #print("C.", {Mom: 5551234567, Dad: 5557654321}) # NameError: name 'Mom' is not defined #print("D.", {Mom: '5551234567', Dad: '5557654321'}) # NameError: name 'Mom' is not defined
upvoted 1 times
...
Sanela
6 months, 1 week ago
A dictionary cannot hold variable as key (since no other items have been created before), so C and D aren't correct answers. Keys should be literals here
upvoted 1 times
...
25Topaz
11 months, 2 weeks ago
Selected Answer: AB
"NameError: name 'Mom' is not defined " will happen as it will as it it will think Mom is a variable that is undefined since it is not in '' or "" like string should be
upvoted 1 times
...
JeffriXu
1 year ago
Selected Answer: AB
so crazy, who set the correct answers to CD??? you go try it
upvoted 2 times
...
Valcon_doo_NoviSad
1 year, 1 month ago
Selected Answer: AB
A lot of correct answers in the comments are wrong in one thing - a dictionary key does not have to be quoted, unless it's a string. It is an important distinction to saying "keys should be quoted" which is not the case.
upvoted 2 times
...
Acid_Scorpion
1 year, 2 months ago
Selected Answer: AB
Correct answer is A and B, as keys should be "quoted"
upvoted 1 times
...
Sadaiyan
1 year, 6 months ago
Selected Answer: AB
Correct answer are A and B
upvoted 1 times
...
dicksonpwc
1 year, 7 months ago
Correct answer are A and B
upvoted 1 times
...
Norbiox
1 year, 11 months ago
Of course AB, according given criteria. CD could work also if Mom and Dad are classes but this isn't mentioned in question.
upvoted 3 times
Valcon_doo_NoviSad
1 year, 1 month ago
It does say "...assume no other items have been created before" though, so those shouldn't be classes.
upvoted 1 times
...
...
jaimebb
2 years ago
Selected Answer: AB
key needs quote
upvoted 1 times
...
Hanjito
2 years, 1 month ago
Selected Answer: AB
Keys without quotes won't work, it's A and B. In C and D, Mom and Dad represent variables that are not defined (error)
upvoted 1 times
...
N9
2 years, 2 months ago
Selected Answer: AB
Key need quote e.g. 'Mom' : value
upvoted 1 times
...
Jnanada
2 years, 3 months ago
C and D has Key without quotes. So answer should be A and B
upvoted 1 times
...
PremJaguar
2 years, 4 months ago
Selected Answer: AB
option A and B is right
upvoted 1 times
...
Van_Rossum
2 years, 4 months ago
Selected Answer: AB
Note the condition: "..no other items have been created before." Without enclosing Mom and Dad inside quotes(to make then string literals), they remain undefined variables.
upvoted 1 times
...
Suvabrata
2 years, 5 months ago
Correct answers are A and B. Since the keys in a dictionary should be in quotes, so C and D are incorrect. The values in a dictionary may or may not be under quotes, so A and B are correct.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...