p2
p2
UNIT2
If Statement:
The if statement is the most simple decision-making statement.
It is used to decide whether a certain statement or block of statements will be
executed or not.
Flowchart of If Statement :
Example:
a = 33
b = 200
if b > a:
print("b is greater than a")
Output:
b is greater than a
Python Elif Statement:
Here, a user can decide among multiple options. The if statements are executed from
the top down.
As soon as one of the conditions controlling the if is true, the statement associated with
that if is executed, and the rest of the ladder is bypassed. If none of the conditions is
true, then the final “else” statement will be executed.
Flowchart of Elif Statement in Python:
Example:
a = 33
b = 33
if b > a:
elif a == b:
Output:
a and b are equal.
Python else statement:
Example:
x = 2
if x > 3:
print("YES")
else:
print("NO")
Output:
No