Skip to main contentSkip to solution

_______ statement in python is used to test an expression in the program code.

Solution

✅ Correct Option: 2

The assert statement tests an expression (a condition) in the code. If the expression is True, the program continues. If it is False, Python raises an AssertionError, optionally with a message, as in assert x > 0, "x must be positive".


Try: marks a block of code in which exceptions are to be handled, and does not test a condition.

Finally: a block that runs whether or not an exception occurred, usually for cleanup.

Catch: not a Python keyword. Python uses except, while catch belongs to Java and C++.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question