Day 4
if Statements
With If statements, if the condition evaluates to True, the statements are carried out. Otherwise, they aren't carried out.
An if statement looks like this:
One Simple Example:
Output :
Ok, but when is life ever that simple? Sometimes we’ll have to perform more complex checks. But that’s no problem, because if statements can be nested, one inside the other.
This means that the inner if statement is the statement part of the outer one. This is one way to see whether multiple conditions are satisfied.
The if else statement can also be used by extending it by using the elseif statement. The shortform of the elseif statement in python is elif.
Sample code:
NOW! IT'S TIME FOR THE END LESSON QUESTIONS :
What is the output of the program:
x = 50
if x <= 19 :
print ("The number is less then or equals to 10")
elif x <=49 :
Print ("The number is less then or equals to 40")
else :
print ("The number is more than or equals to 50 ")
COMMENT THE ANSWER... ///