Python Institute PCED - Certified Entry-Level Data Analyst with Python - PCED-30-02 Exam Practice Test

You want to safely read the contents of a file named records.txtand store them in a list. Your requirements are:
- The file should be automatically closed after reading,
- The code should check whether the file exists before opening it, and
- It should handle missing file errors gracefully.
Which of the following is the most appropriate way to accomplish this task in Python? Select the best answer.
Correct Answer: B Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A program uses slicing on a string "Python". The expression s[1:4] is evaluated. Which substring will be returned?
Correct Answer: D Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A script defines a variable x = None and checks its truth value using a conditional statement. The developer wants to understand how Python evaluates None in Boolean contexts. What will bool(x) return?
Correct Answer: B Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
A program uses while False: followed by print statements inside the loop. The developer expects output. What will actually happen during execution?
Correct Answer: C Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
You are reviewing a report that compares the number of weekly client meetings and project completion rates across teams. The table below summarizes the data for each team:

Which statement best describes the data shown above? Select the best answer.
Correct Answer: B Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).
You are analyzing survey results from students about their favorite colors. The list colorsstores individual responses:

You want to:
- find the number of unique colors mentioned using NumPy, and
- determine how often each color was chosen using Counter.
Which code snippet correctly performs both tasks? Select the best answer.
from numpy import unique
Correct Answer: A Vote an answer
Explanation: Only visible for PassTestking members. You can sign-up / login (it's free).