Is the question is wrong ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is the question is wrong ?

I executed this program and the output was 3 ?!

23rd Jul 2018, 12:31 PM
Ashwin Bharathithasan
Ashwin Bharathithasan - avatar
6 Answers
+ 10
This is because the assertion evaluated False whereas the first one was True so it will output like above Python's assert statement is a debugging aid that tests a condition. ... But if the assert condition evaluates to false, it raises an AssertionError exception with an optional error message. The proper use of assertions is to inform developers about unrecoverable errors in a program.
23rd Jul 2018, 12:41 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 9
Ashwin Bharathithasan Which program ?? Be clear while asking 😊
23rd Jul 2018, 12:33 PM
Mohammad Amir Aqeel
Mohammad Amir Aqeel - avatar
+ 9
which code? can you please share the link of that code then you will get some helpful answer
23rd Jul 2018, 12:34 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
print(0) assert h != w print(1) assert False print(2) assert True print(3)
23rd Jul 2018, 12:34 PM
Ashwin Bharathithasan
Ashwin Bharathithasan - avatar
0
in the question, they asked the highest no in this program,the and is 1 ...
23rd Jul 2018, 12:35 PM
Ashwin Bharathithasan
Ashwin Bharathithasan - avatar
0
but my output was 3?
23rd Jul 2018, 12:35 PM
Ashwin Bharathithasan
Ashwin Bharathithasan - avatar