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

Latest articles

1,677 articles · page 27 of 140
Python practice

Print exception details

Write a Python program that prints the type, message and line of a caught exception. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Ask until the input is valid

Write a Python program that keeps asking for a number until a valid one is entered. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
Python practice

Use assert for checks

Write a Python program that uses `assert` to check a condition and handles the AssertionError. Step-by-step explanation, colour-coded code and real output.

1 min readRead →
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 →

Preparing for a QA interview?

Take free timed mock tests with answers and explanations.