SQA Tools Blog

Learn testing and automation, one article at a time

Free tutorials, solved practice problems and interview prep for QA and automation engineers: Python, Playwright, Selenium, SQL, Git and more.

1,677Articles
1,141Solved Python problems
7Topics
100%Free

Python practice articles

1,137 articles · page 12 of 95 · Clear filters
Python practice

Retry on failure

Write a Python program that retries an unreliable operation up to 3 times. Step-by-step explanation, colour-coded code and real output.

2 min readRead →
Python practice

Handle a missing file

Write a Python program that opens a file and handles the case where it does not exist. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Chain exceptions with raise from

Write a Python program that converts a low-level error into a clearer one and keeps the cause. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Log and re-raise

Write a Python program that logs an error and then re-raises it to the caller. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Custom exception class

Write a Python program with a custom `InsufficientBalanceError`. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Raise an exception

Write a Python function that raises ValueError for an invalid age. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Use the finally block

Write a Python program that shows `finally` always runs. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Use the else block

Write a Python program that uses `else` to run code only when no exception occurred. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Catch several errors in one block

Write a Python program that catches ValueError and TypeError in one except block. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Several except blocks

Write a Python function that handles TypeError and ZeroDivisionError separately. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Handle an index out of range

Write a Python program that reads a list item by index and handles invalid indexes. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Handle invalid integer input

Write a Python program that converts text to an integer and reports invalid values. Step-by-step explanation, colour-coded code and real output.

1 min readRead →

Preparing for a QA interview?

Take free timed mock tests with answers and explanations.