What is the highest number printed by this code? print(0) assert "h" != "w" print (1) assert False print(2) assert True print(3) | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
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)

22nd Oct 2019, 11:52 AM
Naryan Poudel
7 ответов
+ 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).
25th Oct 2019, 4:29 PM
Hind
0
4th Jul 2020, 5:33 AM
Aman jangid
0
1
25th Dec 2020, 12:19 AM
Oumar TOURE
0
1
29th Dec 2020, 5:33 AM
AkileS .
0
print(0) assert "h"! = "w" print(1) assert false print(2) assert true print(3) output : 1
25th May 2021, 12:13 PM