CodeHS Python Level 1 Exam Prep
Free practice questions

Free CHS-P1 Practice Questions

10 exam-style questions with answers and explanations, straight from our 1,030-question bank. Tap an answer to check yourself. When you're ready, take the scored version in the free practice test.

Start the free practice test → ★★★★★4.9/5 from 2,400+ candidates · No signup

The CHS-P1 exam has 45 questions and runs 1 hours 30 minutes.

These 10 free CHS-P1 questions are organized by exam domain, so you can see how each part of the CodeHS Python Level 1 blueprint is tested. Reveal the answer and explanation under each question.

Domain 1: Data Types and Operators

Question 1

In a Python 3 conveyor simulation, emergency_stop is True when the emergency-stop button is pressed, and guard_closed is True when the guard is closed. The simulator must request a stop if the button is pressed OR the guard is open. It must not request a stop when the button is released and the guard is closed. Both inputs are Boolean. Which expression should be assigned to stop_required?

Show answer & explanation

Correct answer: A - `emergency_stop or not guard_closed`

Question 2

A build-status dashboard defines its success score as the percentage of checks that passed among checks that actually ran. Skipped checks are excluded. A score of at least 70% is HEALTHY; a lower score is REVIEW. Inspect this Python 3 calculation: ```python passed = 18 failed = 6 skipped = 16 score = passed // (passed + failed) * 100 ``` Which assessment correctly identifies both the code's score and the status the dashboard should report from these data?

Show answer & explanation

Correct answer: C - The code gives 0%; the correct status is HEALTHY at 75%.

Domain 2: Conditionals

Question 3

Routing rules assign integer scores from 0 through 100 to exactly one category: 80-100 is "priority", 50-79 is "standard", and 0-49 is "low". A ticket scoring 87 is incorrectly routed by this Python 3 code: ```python score = 87 if score >= 50: route = "standard" elif score >= 80: route = "priority" else: route = "low" ``` A maintainer may alter just one line. Select the revision that classifies every allowed score correctly, not merely the displayed ticket.

Show answer & explanation

Correct answer: B - Replace `if score >= 50:` with `if 50 <= score < 80:`.

Domain 3: Loops

Question 4

An import filter receives entry codes, empty separators, and an END marker. Follow the Python 3 scan below through the marker: ```python entries = ["A17", "", "B04", "END", "C09"] accepted = [] for entry in entries: if entry == "": continue if entry == "END": break accepted.append(entry) ``` Which codes remain in accepted, in their stored order?

Show answer & explanation

Correct answer: D - `["A17", "B04"]`

Question 5

Inspection records are stored from oldest to newest. This Python 3 loop is intended to visit every other record, starting with the newest, but it misses A1: ```python records = ["A1", "B2", "C3", "D4", "E5"] for i in range(len(records) - 1, 0, -2): print(records[i]) ``` The required output is E5, C3, A1, each on its own line. Keeping the print statement, choose the replacement loop header that produces that sequence.

Show answer & explanation

Correct answer: D - `for i in range(len(records) - 1, -1, -2):`

Domain 4: Program Structure

Question 6

A unit test checks console output separately from a function's returned value. Consider this Python 3 definition and call: ```python def label(code, prefix): print(prefix + code) saved = label(prefix="R-", code="17") ``` What pair of observations should the test expect?

Show answer & explanation

Correct answer: A - It prints `R-17`; `saved` is `None`.

Domain 5: Error Handling

Question 7

Two independent test cases fail in Python 3. Each statement is executed on its own, not after the other. Test 1: ```python quantity = int("8.2") ``` Test 2: ```python quantity = "8" + 2 ``` To give each failure the right diagnostic, how should their exception types be paired?

Show answer & explanation

Correct answer: D - Test 1: `ValueError`; Test 2: `TypeError`.

Domain 6: Lists

Question 8

A job viewer permits a final page with fewer than five entries. Its Python 3 page-selection code is: ```python jobs = ["J1", "J2", "J3", "J4", "J5"] page = jobs[3:8] ``` A reviewer proposes rejecting this page because 8 exceeds the list's length. How should that proposal be assessed?

Show answer & explanation

Correct answer: B - Unnecessary: `page` is `["J4", "J5"]`; the slice stops at the end of the list.

Question 9

An arrival log must retain its original order, while a separate display needs an alphabetically sorted list. Begin with this Python 3 state: ```python arrivals = ["gamma", "alpha", "beta"] ``` Select the implementation that leaves arrivals unchanged and assigns `["alpha", "beta", "gamma"]` to display.

Show answer & explanation

Correct answer: B - ```python display = sorted(arrivals) ```

Domain 7: Strings

Question 10

A command box should accept "start" regardless of letter case or spaces at either end. A user types exactly two spaces, then Start, then two spaces. This Python 3 code prints "rejected": ```python command = input() command.strip().lower() if command == "start": print("accepted") else: print("rejected") ``` Replace only the second line. Which replacement makes the command box follow its stated rule?

Show answer & explanation

Correct answer: C - `command = command.strip().lower()`

That's 10 of 1,030

The full bank has 1,020 more CHS-P1 questions with explanations.

Continue in the free practice test →

View plans