if - else statements in Python

If - else statements in Python


Let's first have a look on Question


  • So, in this question we get an input n (integer).
  • Now, in this question we have to use some Operator ( Logical ).

  • Following 6 Logical operator-
And all other operator will be discussed in Python on Android Python 


Let's understand if-elif with an example -


How Python Works ?

  • First, the program will start from Line 3 ( if b>a ) and if the statement ( b>a ) comes True ,it will print b is greater than a .
  • But in our case it is false.
  • So, the cursor will move to Line No. 5 (a==b) and if statement found True it will show a and b are equal.
  • And that's our Answer !!
  • And elif statement seem false it will move to else statement (which don't contain any operation. It will print what is in print statement after else statement indentation.

Output 
Now moving towards our Real question.

Code -
That's our code .. !! Hope it is Easy for you.

Comments

Popular posts from this blog

Arithmetic Operators in Python

print (Hello world) program in Python