Table of Contents
Python Control Statement
- Using a control statement control the statement and expression of the python program.
if statement
- if statement returns boolean values.
- if the condition is correct it returns a TRUE value otherwise it returns FALSE.
Example
if statement
x = 5
y = 8
if x <= y:
print("x is smaller than y")
Output
x is smaller than y
if-else statement
- The if-else statement returns boolean values.
- if the condition is correct it returns a TRUE value otherwise it returns FALSE.
Example
if-else statement
x = 5
y = 8
if x >= y:
print("x is smaller than y")
else:
print("y is smaller than x")
Output
y is smaller than x