IF-ELSE CONDITION

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 1 (0s)

[Audio] Welcome to today's session. Today, we will delve deep into understanding the "if-else" conditional statements. "iif-else" statement is the best friend of any decision maker..

Scene 2 (14s)

[Audio] Let's meet Mia. She is an aspiring data analyst..

Scene 3 (27s)

[Audio] Mia went to an ATM with her friend Mike to withdraw money. Mia's transaction was successful and she got the money!.

Scene 4 (42s)

[Audio] It was MIke's turn then! Oops! He entered an incorrect pin and hence his transaction went unsuccessful in the first attempt..

Scene 5 (55s)

[Audio] After entering the correct PIN, Mike got his money!.

Scene 6 (1m 8s)

[Audio] Mike was curious to know how ATM verifies the PIN and gives the money. Mia offers to help him to understand how ATM makes the decision for a successful transaction..

Scene 7 (1m 22s)

[Audio] Mia explained to Mike that when we enter the PIN number at the ATM, it checks if the entered PIN matches the correct PIN registered with the account. If they match, the transaction is successful, and money is provided. However, if the PIN numbers don't match, the transaction is unsuccessful..

Scene 8 (1m 44s)

[Audio] Let's use a flowchart to understand the ATM's decision-making process. The crucial condition it checks is whether the entered PIN is correct. If the condition is true, the transaction is successful. If the condition is false, the transaction is unsuccessful..

Scene 9 (2m 4s)

[Audio] Before writing the code in any programming language, let's convert the flowchart into a coded form. We'll use the keyword "if" to check whether the entered PIN is the same as the correct PIN. If this condition is true, a set of statements will be executed. On the other hand, if the condition is false, another set of statements will be executed using the "else" keyword..

Scene 10 (2m 31s)

[Audio] In Python, we can write the code for this simple decision-making process. We use the keyword "if" followed by the condition, which in turn is followed by a colon. Then, we write the statements to be executed in the next line with proper indentation. Similarly, we use the keyword "else" followed by a colon to handle the false condition, and again, we write the corresponding statements in the next line with proper indentation..

Scene 11 (3m 1s)

[Audio] Here is a small quiz for you! Predict the output for this code. Identify the condition in this code. Check whether the condition will evaluate to true or false based on the values of 'a' and 'b'. Based on this, decide what will be the output..

Scene 12 (3m 22s)

[Audio] Hope you have guessed it correctly! The condition is to check whether the numbers are equal. But, they are not equal. Hence, the result!.

Scene 13 (3m 35s)

[Audio] Hope you got a clear idea of decision making using if-else in this session. Don't forget to attempt the post class quiz and practice questions! Thank you! See you in the next session!.