Skip to content

If statement true Python | Example code

  • by

If statement concept works on Boolean true and false. If block codes will execute if the Boolean expression evaluates to TRUE. If the Boolean expression evaluates to FALSE then the code inside the block will not execute.

if expression:
   code(...)

Python example if the statement is a true

Simple example code. Try it at least twice, with different inputs. You will get an extra output result, depending on the input.

weight = int(input("Enter suitcase weigh: "))

if weight >= 50:
    print("There is a $25 charge for luggage that heavy.")

Output:

If statement true Python

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