Anyone Can Code.


What Are Conditionals?

Avi Bhattacharya

Conditionals are used to see if the input meets certain requirements. If it does, then the program executes an algorithm and if these requirements are not met, the program executes a different/alternate algorithm.

Conditionals are mainly used to check whether a condition is satisfied or not. You can also have multiple conditions in a conditional construct to provide alternative condtions to be checked if the previous ones are not met.

Conditional statements are dependent on boolean values i.e. True and False. We can only use conditions which return these values while creating conditional constructs. Other kinds of conditions will not run successfully.

Conditionals become very useful while working with cases where we want to filter data in our program. They can be used to check whether requirements are being met or even to classify things.

An example of where we can use conditionals is by creating a classification for a school. We would have to create conditions to give different students grades based on their academic performance. To simplify this task, we can run a program to classify the grades for each student by creating conditional constructs which will take in the raw data and output each student's results. To do so for multiple students, we would need to use a loop, which we will learn about in the next tutorial. At the end of this tutorial, you will be able to create such a classification for one student.

That's it for this tutorial! Click Next to access the next tutorial!

❮ Back

Next ❯

Copyright © 2020, Q-Programming | Created by Arjun Sodhi, Balpreet Juneja and Sammarth Kumar | Developed and Designed by Sammarth Kumar