Exam Information
Free practice questions with explanations
Python Institute PCEP-30-02 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 10
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Computer Programming Fundamentals
A logistics team maintains a Python script that reads sensor readings from a text file. A junior developer wrote the following line to convert a reading and then check it: reading = "42" followed by if reading > 40: print("high"). The script raises a TypeError at runtime when the file is processed. The team lead insists the code must remain a single readable line for a log parser that expects one statement per line, and the fix must not change the input file format. Which change is the BEST fix?
Correct Answer: CExplanationPython does not implicitly convert between str and int, so comparing the string "42" to the integer 40 raises a TypeError. Calling int(reading) converts the value explicitly, and the comparison then works as intended while the file format stays unchanged. Using & is a bitwise operator that does not compare magnitudes and would itself fail on a string. Wrapping the code in a try block hides the defect rather than fixing it. Comparing two strings with > does not compare numeric values, since comparison is lexicographic, so "42" > "40" is true only by character order and gives wrong results in general.
-
2 Question 2 Multiple choice Control Flow
A warehouse system must scan pallet IDs from a list and stop processing as soon as it finds the first pallet marked as damaged, while skipping pallets that have already been logged as archived. The team wants the loop to be correct and readable for an audit review. Which TWO implementations meet these requirements? (Choose two.)
Correct Answer: A, CExplanationThe loop in A uses continue to skip archived pallets and break to stop at the first damaged pallet, which is exactly the required behaviour. The loop in C also satisfies the requirement, because pass does nothing for archived pallets and returning from inside the loop ends processing at the first damaged pallet, provided the code is placed in a function. Option B never reaches archived pallets only by accident and can loop forever. Option D inverts the control statements and stops at archived pallets. Option E keeps running after damage is found, violating the stop condition.
-
3 Question 3 Order list Data Collections
A procurement analyst receives a CSV export of supplier records in which the first column is supplier name and the second is the number of units delivered. She must build a dictionary mapping each supplier to the total units delivered, using a list of rows already read into memory as tuples. Arrange the steps in the correct order.
Drag the steps into the correct order, or use the arrows.
- Add the units to the existing total for that supplier, using get with a default of 0.
- For each row, read the supplier name from index 0 and the units from index 1.
- Return or print the completed dictionary after the loop finishes.
- Create an empty dictionary to hold totals keyed by supplier name.
- Iterate over each row tuple in the list of rows.
Correct Answer:- Create an empty dictionary to hold totals keyed by supplier name.
- Iterate over each row tuple in the list of rows.
- For each row, read the supplier name from index 0 and the units from index 1.
- Add the units to the existing total for that supplier, using get with a default of 0.
- Return or print the completed dictionary after the loop finishes.
ExplanationThe dictionary must exist before any row is processed, so creating it comes first. Each row must then be iterated, and the fields extracted by index before they can be used. Totals are updated using get with a default of 0, which avoids a KeyError for new suppliers. The result is only available once the loop has completed, so returning or printing the dictionary comes last. Placing the output step before the loop would yield an empty or partial result.
-
4 Question 4 Single choice Functions and Exceptions
A payroll script calls compute_bonus(salary, rate) inside a loop over 5,000 employees. The function uses an exception handler to guard against a missing rate, and the team wants any failure logged without the script crashing, while still surfacing unexpected errors such as a TypeError from a corrupted record. Auditors require that the original exception type and traceback remain available for investigation. Which exception-handling structure is the BEST choice?
Correct Answer: CExplanationCatching the specific KeyError handles the expected missing-rate case, logging it and returning a safe value, while leaving unrelated exceptions such as TypeError to propagate with their original traceback. Because no broad handler swallows them, the auditors' requirement is met. A bare except catches everything, including errors the team needs to see, and returning None obscures the failure. Catching Exception and re-raising is closer, but it still handles a broader set than needed and is not the most precise structure for a known missing key. Suppressing BaseException silently would also swallow system-level exits and hides defects entirely.
-
5 Question 5 Dropdown Data Collections
A marketing team stores campaign data in a tuple that must never change once created, and the analyst needs to read the second element and extract a slice of the first three elements. Complete the statements by selecting the correct value for each blank.
Choose the correct value for each blank.
campaign = ("spring", 1200, 0.35, "email", 88)
second = campaign[]
first_three = campaign[]Correct Answer:campaign = ("spring", 1200, 0.35, "email", 88)
second = campaign[1]
first_three = campaign[0:3]ExplanationIndexing starts at zero, so the second element of the tuple is found at index 1, which holds 1200. The first three elements are obtained with the slice 0:3, which includes indexes 0, 1 and 2 and excludes index 3. Index 0 would return the campaign name rather than the second element. The slice 1:4 begins at the wrong position, and 3: returns everything from index 3 onward, which is the opposite of what the analyst needs.
-
6 Question 6 Single choice Configuration Management
A consulting firm maintains a shared Python utility library used by three internal teams. A developer needs to change the default timeout from 30 to 60 seconds for all teams. The utility file is imported by code that another team has pinned to the old behaviour through a configuration module, and the change must not break that team's build, which is frozen for the quarter. The developer must make the change in a way that is reversible and keeps the team's behaviour intact. Which approach BEST meets these constraints?
Correct Answer: CExplanationAdding a keyword argument with the new default while leaving the old default untouched lets the frozen team keep receiving 30 seconds through their existing calls, and the change can be reverted or adopted gradually. Editing the default directly changes behaviour for the frozen team's build, which the constraints forbid. Hardcoding 60 removes the ability to configure the value at all and still changes behaviour for everyone. Renaming and removing the old function breaks every caller at once, violating the requirement that the frozen build continues to work.
-
7 Question 7 Drag and drop Operators and Syntax Fundamentals
A data validation module must evaluate several conditions on user input before accepting it. The reviewer wants each condition expressed with the correct operator category so the expression behaves as intended. Match each requirement to the operator type that meets it.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
Add a numeric value to a running totalStore a computed result in a variableCombine two conditions so both must be trueCheck that two values are equal to each otherrelational operatorbitwise operatorBoolean operatorassignment operatorarithmetic operatorCorrect Answer:- Check that two values are equal to each other → relational operator
- Combine two conditions so both must be true → Boolean operator
- Add a numeric value to a running total → arithmetic operator
- Store a computed result in a variable → assignment operator
ExplanationEquality checks use relational operators such as ==, which compare two values and return a Boolean. Requiring both conditions to hold uses Boolean operators like and. Accumulating a sum relies on arithmetic operators such as +, and placing a result into a variable is handled by an assignment operator such as =. Bitwise operators manipulate individual bits of integers and do not fit any of the stated requirements, so they serve as the unused target.
-
8 Question 8 Single choice User Management
A healthcare SaaS administrator must grant an external auditor read-only access to patient-scheduling reports in a shared reporting workspace. The auditor needs no ability to edit records, create dashboards, or export data. The organisation uses profiles for base access, permission sets for additional capabilities, and has a limited supply of full-user licenses while the auditor requires only a basic read licence. Which assignment BEST meets these requirements with the least privilege?
Correct Answer: AExplanationStarting from a minimal profile and layering a single permission set that exposes only the scheduling reports gives the auditor exactly the access required. Pairing that with a basic read licence avoids consuming the scarce full-user licences. Starting from the System Administrator profile grants excess rights that must then be stripped, which is error-prone. Relying on hidden controls does not enforce permissions, and a full-user licence wastes a constrained resource while providing unnecessary capability.
-
9 Question 9 Single choice Automated Jobs & Scheduled Maintenance
An operations team runs a nightly scheduled job that imports ledger data and writes application logs. Over six months the application log has grown to several gigabytes, slowing the administrators' review. The compliance policy requires that logs be retained for 90 days, and the team must avoid any action that could remove logs still inside that window. The job also creates obsolete scheduled entries whose target scripts were decommissioned. Which maintenance action should the administrator perform FIRST?
Correct Answer: CExplanationThe retention requirement is the deciding constraint, so the first action is to review the log and remove only entries older than 90 days, which keeps compliant records intact. Deleting the whole log would breach retention for recent entries. Disabling the import job stops a legitimate business process to solve a storage problem and is not a maintenance step. Removing scheduled job records without checking their history risks losing evidence of past runs that may be needed for audit, so verification should precede any deletion.
-
10 Question 10 Order list Control Flow
A quality team writes a Python script that scans a list of sensor readings and reports the first reading that exceeds a threshold, skipping any reading that is None. The reviewer requires the logic to be built from the outside in so the iteration and guards are correct. Arrange the steps in the correct order.
Drag the steps into the correct order, or use the arrows.
- Check whether the current reading is None and continue to the next reading if so.
- Check whether the reading exceeds the threshold and break out of the loop with that value if so.
- Start a for loop that iterates over each reading in the list.
- Print the first offending reading or a message when none was found.
- Define the threshold value and the list of readings to scan.
Correct Answer:- Define the threshold value and the list of readings to scan.
- Start a for loop that iterates over each reading in the list.
- Check whether the current reading is None and continue to the next reading if so.
- Check whether the reading exceeds the threshold and break out of the loop with that value if so.
- Print the first offending reading or a message when none was found.
ExplanationThe threshold and data must be defined before any loop can reference them. The loop must then be established so each reading is visited. The None guard uses continue to skip invalid values before the threshold comparison, since comparing None with a number would raise a TypeError. The break happens only once an offending reading is detected, and the reporting step follows the loop so it can handle both the found and not-found cases.
These are 10 of the 30 questions in the full PCEP-30-02 pack.
Get All 30 QuestionsGet all 30 questions & answers
Full access options for Python Institute PCEP-30-02
Self-study
PDF Version
- 30 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 30 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 30 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the PCEP-30-02 Exam (PCEP - Certified Entry-Level Python Programmer) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.