Learn Before
Code

if statement examples

a=1 if a==10: print("the boolean expression is true") elif a==5: print("the boolean expression in elif is true") else: print("the boolean expression in if and elif is false")

Result

the boolean expression in if and elif is false
a=4 if a>6: print("a is greater than 6") else: print("a is less than or equal to 6")

Result

a is less than or equal to 6
a = "1cademy" if a =="1cademy": print("Welcome to 1cademy") print("Welcome everyone")

Result

Welcome to 1cademy Welcome everyone

0

1

Updated 2021-01-26

Tags

Python Programming Language

Data Science