It is similar to that of other languages. The if statement contains a logical expression using which data is compared and a decision is made based on the result of the comparison.
If the boolean expression evaluates to TRUE, then the block of statement(s) inside the if statement is executed. If boolean expression evaluates to FALSE, then the first set of code after the end of the if statement(s) is executed.
var1 = 100
print "1 - Got a true expression value"
var2 = 0
print "2 - Got a true expression value"
print "Good bye!"
When the above code is executed, it produces the following result −
1 - Got a true expression value
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.