Decision Making
Learn about decision making and looping in Python
We'll cover the following
In any programming language that creates good programs, we need the ability to check conditions and change the flow of the program accordingly. We want to make decisions in the program and take action according to those decisions or conditions. For example, say we want to write a code for a healthcare plan premium generation. We collect the user name, date of birth, and gender. Now, based on the user’s date of birth, we want to offer a premium or discount. We want to calculate the premium based on the age of the user. If the user is under 20, their premium would be lower. These kinds of actions or tasks need to utilize the conditional flow of the program.
Python also supports decision-making using if statements. Python decision making includes if
statements, if-else
statements, nested if
statements, elif
statements, and others.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.