Usually, you need to make some decisions in the flow of your program. These decisions are made using flow control statements that determine the statements to execute. In Python If, Elif, Else statements are used to control the flow of a program.
|<=||Less Than or Equals|
|>=||Greater Than or Equals|
If statement is the most commonly used control statement. Code block under if statement is executed, when the condition evaluates to true.
x = 100 if x == 100: print("x is equal to 100.")
Elif (Else If) statement follows an if-statement or another elif statement. Elif statement means, check this condition if all if/elif statements above are evaluated to false.
score = 90 if score == 100: print("Congratulations, you have a perfect score!") elif score>70: print("Well done, you have passed.")
score = 100 if score == 100: print("Congratulations, you have a perfect score!") elif score > 90: print("Congratulations, you scored very well.") elif score>70: print("Well done, you have passed.") else: print("You have failed, you need to practice more.")