If true Python concept | Example code

If-statement” is a special way to control the flow of code. It will compute if a statement is true or false in Python. The true condition will execute the code and the false condition won’t execute the code.

Example If true Python

True and False are Booleans in Python. The if conditional statements use Boolean math to compute their Boolean state.

if True:

if False:


If true Python

If with condition

var = 1

if var == 1:
    print("Var value is 1")

Output: Var value is 1

Multiple conditions

a = 1
b = 1

if a == 1 and b ==1 :
    print("a and b value is 1")

Output: a and b value is 1

Do comment if you have any doubts and suggestions on this Python basic concept.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.