Python if True statement | Example code

Python if True statement works on if the given expression is true. If the statement evaluates the condition as the boolean expression evaluates if it’s TRUE, then the block of the statement(s) inside the if statement is executed.

The general Python syntax for a simple if statement is:

    if condition :

Python if boolean true example code

Simple if Statements, If it is true that the age is greater than 50, then print the statement about the discount, and If the condition is not true skip the block. In this example input form user.

age = float(input("Enter age: "))
if age > 50:
    print("50% discount")


Python if True statement

Do comment if you have any doubts and suggestions on this python if true statement code.

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.