Program Flow And Control Statements:

3 Min Read

1. If Statement:

It is used in decision making operations. The program runs only until the given condition is true and the program will terminate if the condition gets false. As a real world example: A program to check either pass or fail.  


marks = 44
if marks > 40: 



In the above program, the student status of either pass or fail is checked. The mark is 44 which is greater than 40. So, the pass statement is printed. 

2. If else statement:

It is used in decision-making operations. The program checks whether a given condition is true or false. If the condition is true, it will run the block of statements and if the condition is false, the else part statement will be run. As a real-world example: Checking eligibility for applying for citizenship!


age = int(input("Enter your age: "))

if age >= 16: 
		print("You can apply for citizenship.")
    		print("Candidates must be 16 or above age to apply.")


Enter your age: 12
Candidates must be 16 or above age to apply.

In the above program, the eligibility criteria of whether the candidate can apply or not for citizenship is checked. If the candidate age is 16 or more, the “You can apply for citizenship.” The statement is printed and if the candidate age is below 16 years, the “Candidates must be 16 or above age to apply.” statement is printed. 

  3. If elif else statement:

It is quite similar to the if else statement. But the only difference in the if-else-elif statement is it allows checking multiple conditions. Eg; A program to check two numbers either which are greater where two conditions are checked either they are greater or  equal to each other. 


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

if a > b: 
    		print("First number is greater than second number.")
elif a == b:
  		print("Both numbers are equal")    
    		print("Second number is greater than the first number.")


Enter first number: 3
Enter second number: 4
Second number is greater than the first number.

In the above program two numbers were asked from the user. After that,

The numbers were checked to see which one is the greater number. Also, by elif statement either they were equal or not is checked.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *