Exam PCEP-30-02 Topic 1 Question 6 Discussion
Actual exam question for Python Institute's PCEP-30-02 exam
Question #: 6
Topic #: 1
Question #: 6
Topic #: 1
Assuming that the phonc_dir dictionary contains namemumber pairs, arrange the code boxes to create a valid line of code which retrieves Martin Eden's phone number, and assigns it to the number variable.


Suggested Answer:

Explanation

number = phone_dir["Martin Eden"]
This code uses the square brackets notation to access the value associated with the key "Martin Eden" in the phone_dir dictionary. The value is then assigned to the variable number. A dictionary is a data structure that stores key-value pairs, where each key is unique and can be used to retrieve its corresponding value. You can find more information about dictionaries in Python in the following references:
[Python Dictionaries - W3Schools]
[Python Dictionary (With Examples) - Programiz]
[5.5. Dictionaries - How to Think Like a Computer Scientist ...]
by Rebecca at Jun 17, 2024, 08:43 AM
Contact Us
If you have any question please leave me your email address, we will reply and send email to you in 12 hours.
Our Working Time: ( GMT 0:00-15:00 ) From Monday to Saturday
Support: Contact now
Comments
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.
Report Comment
Commenting
You can sign-up / login (it's free).