Beginning in Python programming? If else statement is quite a basic statement in any programming language.
If else is used in evaluating conditions or basically, it
will tell the program what to do next if a specified match or input is
encountered.
In if else statement, depends on the conditional statement
that is set then the next logic will determine on what action or execution will
be performed.
For example, after a match pattern occurs then the next
statement will execute an action but sometimes after a match occurs you don't
want to do anything instead the else statement will show what action or logic
to be executed.
In Python "continue" statement does not mean that
it will continue to execute the code after the "continue" statement,
instead it will break that execution and goes to the top of the code and
continue the next course of action.
However, "pass" statement in Python will mean
literal "pass". So, if "pass" is used in an if else
statement then it would mean it would bypass the "else" part and continue
to the next statement after else.
Here's an example:
getinput = input("Please enter a letter:\n")
if getinput == 'x':
pass
else:
print
("Oops not x")
print ("done")
Output if "x" is entered as input: (if an input matches 'x' else is bypass)
Please enter a letter:
x
done
>>>
Output if other letter is entered as input: (if input is not 'x' both else and last statement is printed)
Please enter a letter:
c
Oops not x
done
>>>
================================
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment