0
What is the highest number printed by this code? print(0) assert "h" != "w" print (1) assert False print(2) assert True print(3)
answer 1
7 Answers
+ 3
An assertion works by checking whether the expression is true or false.
If it is true, it continues to execute the next function.
If it is false, it stops without moving to the next function.
In this code, âhâ != âwâ is true, because âhâ is not equal to âwâ.
So the function after it is run, which is print(1), and 1 is printed.
Then it moves to the next assertion.
âassert Falseâ is false (because False = False), so the code stops running there.
The output of this code is:
>>>
0
1
>>>
The highest number printed by this code is 1, since the code stopped running before reaching print(2) and print(3).
0
1 is answer
0
1
0
1
0
print(0)
assert "h"! = "w"
print(1)
assert false
print(2)
assert true
print(3)
output : 1
0
1 is the answer
0
Assertions
What is the highest number printed by this code?
print(0)
assert "h" != "w"
print (1)
assert False
print(2)
assert True
print(3)
1
===========
1