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!
New course! Every coder should learn Generative AI!
Try a free lesson
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

22nd Oct 2019, 11:52 AM
Naryan Poudel
Naryan Poudel - avatar
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).
25th Oct 2019, 4:29 PM
Hind
Hind - avatar
0
1 is answer
4th Jul 2020, 5:33 AM
Aman jangid
Aman jangid - avatar
0
1
25th Dec 2020, 12:19 AM
Oumar TOURE
Oumar TOURE - avatar
0
1
29th Dec 2020, 5:33 AM
AkileS .
AkileS . - avatar
0
print(0) assert "h"! = "w" print(1) assert false print(2) assert true print(3) output : 1
25th May 2021, 12:13 PM
Madhavareddy
Madhavareddy - avatar
0
1 is the answer
23rd Jun 2021, 1:58 AM
MR.KBD07
MR.KBD07 - avatar
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
19th Oct 2022, 6:58 AM
Md Hasan Sikder
Md Hasan Sikder - avatar