CONDITIONAL STATEMENTS IN PYTHON:
Conditional statements help computers make decisions when conditions are present. These
statements include an “if” part, which tells the program what to do if the condition is true.
Furthermore, these statements usually include an “else” part, which tells the program what to do
if the condition is false. In Python, there are 6 types of conditional statements used for
decision-making. These include the following: “if” statements, “if-else statements”, “if…Elif…else
statements”, “nested if statements”, “shorthand if statements”, and “shorthand if-else
statements”.
An “if” statement is the most basic of the 6 statements as the code will only be executed if the
condition is present.
An “if-else statement” is used when code needs to be specified when conditions are true or
false.
An “if…Elif…else statement” involves a 3-step process. First, the “if” condition is evaluated. If
the condition is false, then the Elif condition will be evaluated. If the condition is false, then the
“else” statement is executed.
“Nested if statements” allow different “if” statements to be slotted inside one another.
“Shorthand if statements” are used when only one “if” statement needs to be executed inside
the “if” block.
“Shorthand if-else statements” are simplification tools that put both the “if” and “else” statements
in one line of code.
[Link]
s-in-python-for-data-science-beginners/
[Link]
operator