Python Quiz for Testing

Python Quiz for Testing – 01

The “Python Quiz for Testing” is devised to evaluate the understanding and practical skills of aspirants in Python programming. Through a series of meticulously crafted questions, the quiz gauges the test-takers’ grasp of Python’s fundamentals, its applications, and the ability to solve real-world problems using this versatile programming language. The goal is not only to test but also to reinforce learning, making the participants well-versed in the nuances of Python, thereby paving the way for their successful endeavors in the technological realm.

Read More:Python Testing

0%
7

Python Testing – 01

Level: Advanced

1 / 10

1. How would you test that a function `open_file(file_path)` raises a FileNotFoundError when the file does not exist?

2 / 10

2. How would you test that a function `parse_json(json_str)` raises a json.JSONDecodeError when the input string is not a valid JSON?

3 / 10

3. How would you test a function `divide(a, b)` that should return the result of `a / b`?

4 / 10

4. How would you test a function `add(a, b)` that returns the sum of `a` and `b`?

5 / 10

5. How would you test that a function `calculate_square_root(n)` raises a ValueError when `n` is negative?

6 / 10

6. How would you test a function `is_even(n)` that returns True if `n` is even and False otherwise?

7 / 10

7. How would you test that a function `validate_email(email)` raises a custom InvalidEmailError when the email is invalid?

8 / 10

8. How would you test a function `get_full_name(first_name, last_name)` that returns the full name in the format ‘First Last’?

9 / 10

9. How would you test a function `multiply(a, b)` that should throw a TypeError when either `a` or `b` is not a number?

10 / 10

10. How would you test that a function `divide(a, b)` raises a ZeroDivisionError when `b` is zero?

Your score is

0%