+ 1

Whats difference b/w assertion and if ?

Assertion vs if

28th Sep 2016, 5:54 PM
Md Rashid
Md Rashid - avatar
2 Respostas
+ 4
This is the different b/w the two : if statement will be tested if the condition(s) provided return true then the block of if statement will be executed and if condition return false then the block will not be executed and next conditions will be tested (if there's any like 'elif' or 'else') but unlike assertion will only execute next line of code iff the condition tested returns true , otherwise it will terminate the program and the rest of the code will not be executed....Thank you.
14th Oct 2016, 6:22 AM
Isack T Nicholaus
Isack T Nicholaus - avatar
+ 3
assert is meant for testing your code for checking it does what you think it does, if is for getting the code to do different things depending on some condition
29th Sep 2016, 1:11 PM
Phil
Phil - avatar