0
This assertions is not clear... I need help please
print(1) assert 2 + 2 == 4 print(2) assert 1 + 1 == 3 print(3)
2 Respuestas
+ 3
1. Output of the 5-question quiz you posted is:
1
2
Because 1+1 ==3 is false and trigger AssertError
Therefore 3 will not be printed
You can put the code in code playground and run to test yourself.
2. Assert is used in debugging program when there is no syntax error but the variable must fit certain condition for the program to run properly
3. Here is a demo for assertion in Python :
https://code.sololearn.com/cBc5B5dnk7BJ/?ref=app
4. JavaScript has assertion too, a demo:
https://code.sololearn.com/WA4GNuWfI8b0/?ref=app
In JS, program continue to run after assertion error. In Python, program terminate once assertion error is raised.
0
thank you