Tosa Python Exam Prep
Free practice questions

Free TP Practice Questions

10 exam-style questions with answers and explanations, straight from our 1,034-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 TP exam has 35 questions and runs 1 hours 30 minutes.

These 10 free TP questions are organized by exam domain, so you can see how each part of the Tosa Python blueprint is tested. Reveal the answer and explanation under each question.

Domain 1: Fundamentals and Applications

Question 1

A manufacturer wants hourly production reports from a controller that already meets a hard 1-millisecond response deadline. Reporting will run on a separate computer, and the control loop never waits for a report. The team wants rapid development without disturbing the validated timing behavior. How should Python be introduced into this system?

Show answer & explanation

Correct answer: B - Use Python for reporting and leave the validated real-time control loop unchanged.

Domain 2: Language and Syntax

Question 2

A client library accepts a timeout value that is either None or a nonnegative integer. None means to use 30 seconds; 0 means not to wait at all. A developer writes: timeout = value or 30 Tests show that callers requesting 0 seconds unexpectedly wait for 30 seconds. Select the assignment that implements the contract for every permitted input.

Show answer & explanation

Correct answer: C - timeout = 30 if value is None else value

Question 3

A decorator must print the function's name once per call and preserve its return value. This implementation prints normalize, but result becomes None: def log_calls(func): def wrapper(*args, **kwargs): print(func.__name__) func(*args, **kwargs) return wrapper @log_calls def normalize(code): return code.strip().upper() result = normalize(" ab-7 ") Identify the correction that preserves both required behaviors.

Show answer & explanation

Correct answer: D - Replace the call inside wrapper with return func(*args, **kwargs).

Question 4

An import job must save every valid reading, record malformed numeric strings for later review, and let storage failures propagate. Each raw input is a string. Both int(raw) and save_reading(value) can raise ValueError, but only a conversion failure should cause the job to skip that reading. The current handler encloses both calls and continues on any ValueError. How should exception handling be narrowed?

Show answer & explanation

Correct answer: A - Catch ValueError around int(raw) only; record and skip conversion failures, then call save_reading(value) outside that handler.

Domain 3: Data Structures and Objects

Question 5

A job runner prepares a retry record and then inspects the original: job = {"tags": ["queued"], "state": "new"} retry = job.copy() retry["tags"].append("retry") retry["state"] = "ready" print(job["tags"], job["state"]) What appears on the printed line?

Show answer & explanation

Correct answer: A - ['queued', 'retry'] new

Question 6

After joining two pandas DataFrames, an analyst finds that some orders now appear twice: enriched = orders.merge(customers, on="customer_id", how="left") Every order_id in orders is unique, and neither table contains missing customer_id values. The intended result is one row per order. Which finding would explain the duplicated order_id values in enriched?

Show answer & explanation

Correct answer: A - Two customer rows share a customer_id that is used by an order.

Domain 4: Modules and Packages

Question 7

On a Linux host, this command fails with ModuleNotFoundError: No module named 'requests': /srv/orders/.venv/bin/python worker.py The shell's pip command reports that requests is already installed under /usr/lib/python3.10/site-packages. The worker's virtual environment excludes system packages and must remain isolated. Its own pip installation is working. What is the appropriate targeted repair?

Show answer & explanation

Correct answer: B - Run /srv/orders/.venv/bin/python -m pip install requests, then use the existing worker command.

Question 8

billing.py contains reusable functions, but its final top-level statement, send_invoice(), also sends an invoice whenever another module imports billing. Running python billing.py must still send the invoice; importing billing must only make its definitions available. Choose the replacement for that final statement.

Show answer & explanation

Correct answer: C - if __name__ == "__main__": send_invoice()

Domain 5: Code Optimization

Question 9

The following cProfile summary comes from one report-generation run. generate_report directly calls the other three functions; times are in seconds. Function ncalls tottime cumtime generate_report 1 0.08 8.00 parse_row 40000 6.30 6.30 format_label 40000 0.20 0.20 write_output 1 1.42 1.42 Which conclusion correctly identifies where the measured time is being spent?

Show answer & explanation

Correct answer: D - parse_row is the leading optimization target because its self time dominates the run.

Question 10

Shipping policy makes delivery free for subtotals of 50 or more. A developer tests subtotals of 40 and 80 and argues that exercising both branches is sufficient: def shipping_fee(subtotal): return 0 if subtotal > 50 else 5 Which additional assertion exposes the defect that those two tests miss?

Show answer & explanation

Correct answer: D - assert shipping_fee(50) == 0

That's 10 of 1,034

The full bank has 1,024 more TP questions with explanations.

Continue in the free practice test →

View plans