WEBVTT

00:00.000 --> 00:11.000
We'll explore a key concept in programming, conditional statements.

00:11.000 --> 00:20.000
You'll be able to understand what are conditional statements, understanding if, else if, and else statement.

00:20.000 --> 00:23.000
What are conditional statements?

00:23.000 --> 00:29.000
Conditional statements are a way for a program to make decisions based on certain conditions.

00:29.000 --> 00:37.000
Think of them like asking yes or no questions in everyday life and doing something different depending on the answer.

00:37.000 --> 00:47.000
In Python, conditional statements let the computer decide what to do next based on whether something is true or false.

00:47.000 --> 00:49.000
If statement.

00:49.000 --> 00:54.000
And if statement in Python is used to check whether a specific condition is true.

00:54.000 --> 01:00.000
If the condition is true, the code inside the if, block, runs.

01:00.000 --> 01:03.000
If the condition is false, the code is skipped.

01:03.000 --> 01:07.000
Consider you have scored 85% in your exams.

01:07.000 --> 01:09.000
Score equals 85.

01:09.000 --> 01:12.000
The passing criteria is 50.

01:12.000 --> 01:14.000
We will add an if statement.

01:14.000 --> 01:17.000
If score greater than or equal to 50,

01:17.000 --> 01:20.000
print, you have passed the exam.

01:20.000 --> 01:23.000
As you have score, which is greater than 50.

01:23.000 --> 01:31.000
The colon at the end of an if statement is crucial because it tells Python that the following lines are part of the code block.

01:31.000 --> 01:37.000
After running the code, it will show you have passed the exam.

01:37.000 --> 01:45.000
Else if statement, and else if statement allows you to check multiple conditions in a sequence after an if statement.

01:45.000 --> 01:49.000
It runs only if the previous if condition is false.

01:49.000 --> 01:56.000
Now, consider the if statement as you have scored greater than 90% show, excellent.

01:56.000 --> 02:02.000
If score greater than or equal 90, print, excellent.

02:02.000 --> 02:07.000
But as we have score less than 90%, if statement becomes false.

02:07.000 --> 02:13.000
We use an else if statement, else if, score greater than or equal to 50.

02:13.000 --> 02:16.000
Print, you have passed the exam.

02:16.000 --> 02:19.000
Click run to see the result.

02:19.000 --> 02:27.000
Else statement, and else statement in Python is used to run a block of code when all previous if and else if conditions are false.

02:27.000 --> 02:30.000
Consider you have scored 30% in your exams.

02:30.000 --> 02:33.000
Score equals 30%.

02:33.000 --> 02:37.000
We will keep the if and else if statement same as is.

02:37.000 --> 02:45.000
As both the statement are false, we use else statement, else, print, you need to study more.

02:45.000 --> 02:48.000
Click run to see the results.

02:48.000 --> 02:51.000
Conditional statements are essential in programming to make decisions.

02:51.000 --> 02:58.000
You can use them to classify grades based on marks, making your programs interactive and engaging.

02:58.000 --> 03:04.000
Keep practicing to build smarter programs and grow your coding skills.

