Skip to content

Python if True statement | Example code

  • by

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.3.3 (Community Edition)

Windows 10

Python 3.10.1

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

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading