Decision Making In Python Programming Language
In this lesson, we will learn all about decision making in Python. By decision making it means we set some kind of logical conditions in our code to be executed and only when these conditions fulfill the program will take specified action otherwise it didn’t work.
These decision making statements normally provides results in the form of TRUE or FALSE according to the conditions we had specified before. You also need to specify which action should be performed in case of result to be TRUE or FALSE.
We can represent these decision statements in graphical form as follows and these graphical working model almost the same in every programming language.
As you can see above the very first thing is condition specified by us. Based on our specified condition the result will be TRUE or FALSE and after this, appropriate action will be performed accordingly. After all this cycle the statement will be terminated.
Any value that is non-zero or non-null will be considered as TRUE or positive value by Python programming language for his operations and on the other hand, any zero or null value will be considered as FALSE or negative value by Python programming language.
Like any programming language in Python programming language also provides the following decision making statements to complete their operation based on given conditions. All the decision making statements are given below with a complete explanation. Just click the links below to learn about all these statements.
|Sr. No.||Decision Making Statement|
This statement is based on one boolean expression which can be True or False.
This kind of if statement have an optional additional part as else. It will only execute when the boolean expression is False.
|3.||nested if statements
This is a kind of statement in which you can use one if or else statement inside of another if or else statement.