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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

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: CD 🗳️

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, 5 months ago
Selected Answer: AB
option c d has key without quote. so it is not correct key
upvoted 11 times
...
25Topaz
Most Recent 4 months, 1 week 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
5 months, 3 weeks ago
Selected Answer: AB
so crazy, who set the correct answers to CD??? you go try it
upvoted 2 times
...
Valcon_doo_NoviSad
6 months, 2 weeks 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
7 months ago
Selected Answer: AB
Correct answer is A and B, as keys should be "quoted"
upvoted 1 times
...
Sadaiyan
11 months, 3 weeks ago
Selected Answer: AB
Correct answer are A and B
upvoted 1 times
...
dicksonpwc
1 year ago
Correct answer are A and B
upvoted 1 times
...
Norbiox
1 year, 4 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
6 months, 2 weeks ago
It does say "...assume no other items have been created before" though, so those shouldn't be classes.
upvoted 1 times
...
...
jaimebb
1 year, 5 months ago
Selected Answer: AB
key needs quote
upvoted 1 times
...
Hanjito
1 year, 7 months 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
1 year, 7 months ago
Selected Answer: AB
Key need quote e.g. 'Mom' : value
upvoted 1 times
...
Jnanada
1 year, 8 months ago
C and D has Key without quotes. So answer should be A and B
upvoted 1 times
...
PremJaguar
1 year, 9 months ago
Selected Answer: AB
option A and B is right
upvoted 1 times
...
Van_Rossum
1 year, 9 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
1 year, 10 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
...
macxsz
1 year, 11 months ago
Selected Answer: AB
A. dir={'Mom': 5551234567, 'Dad': 5557654321} B. dir= {'Mom': '5551234567', 'Dad': '5557654321'}
upvoted 2 times
...
rocky48
2 years ago
Selected Answer: AB
Answer is A & B. C & D throw : Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Mom' is not defined
upvoted 2 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 ...