+ 1

What???

I want to lean to code and I’m already on module 4, but some things make NO SENSE at all. Like one said, witch is the greatest number, or something like that. 3 was the greatest number but it said 1 was the right answer. I just don’t understand what all of this means, it doesn’t hook into a place in my brain. I don’t know what to do about that kind of thing, and I just want to understand what all the questions and codes mean. Please help!

9th Jan 2018, 12:46 AM
Starlight Ultima
Starlight Ultima - avatar
3 Respostas
+ 3
I'm guessing this is the question you don't understand. What is the highest number printed by this code? print(0) assert "h" != "w" print(1) assert False print(2) assert True print(3) It prints 0. Tests "h" != "w" and finds it is true so it continues and prints 1. Test False and finds it isn't true so it exits looking for code to handle the AssertionError. Therefore, 2 and 3 never get printed.
9th Jan 2018, 1:55 AM
John Wells
John Wells - avatar
0
The ans is 1
27th Apr 2019, 9:11 AM
Rajib Raiyat
Rajib Raiyat - avatar
0
i hope that this is the question that you are referring to What is the highest number printed by this code? print(0) assert "h" != "w" print (1) assert False print(2) assert True print(3) an assertion statement basically checks if some condition is true; if the condition is true,it does nothing and the code will run normally if the condition is false,it halts the code in question will therefore print 0.Tests that "h" != "w" and find it is true so it continues and print 1. the number 2 and 3 will not be printed since the code will be halted due to the false assertion statement.the highest number to be printed by this code will therefore be 1
23rd Jul 2019, 11:21 AM
austin nyoike