Assert and Assertion in Python - Integrated Circuits - - An Online Book - |
||||||||
Integrated Circuits http://www.globalsino.com/ICs/ | ||||||||
Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix | ||||||||
================================================================================= Assertion is a programming concept used while writing a code where the user declares a condition to be true using assert statement prior to running the module. The assertions assert or guarantee a condition to be true. If the condition is True, the control simply moves to the next line of code. In case if it is False the program stops running and returns AssertionError Exception. They are primarily used during the development phase to check assumptions about the program:
The assert statement takes an expression and evaluates it. If the expression evaluates to True, the program continues execution as normal. However, if the expression evaluates to False, the assert statement raises an AssertionError exception, halting the program's execution, for instance, the code: Output: ============================================ Add elbow, curve, straight line connectors into an existing PowerPoint file: code: Output:
|
||||||||
================================================================================= | ||||||||
|
||||||||