IF ELSE Statements in Python – Conditional Statements in Python

🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!

🖥️ IF ELSE Statements in Python – Conditional Statements in Python

You know how to use an IF statement to conditionally execute a single statement, or a block of several statements. It is now time to find out what else you can do when you want to control the execution flow of your program.

Sometimes, you want to evaluate a condition and take one path if it is True, so that one thing or more can happen, but specify an alternative path when it is not, and something else happens. This, is accomplished with an ELSE clause in Python, which executes a statement in case all the tested expressions are False – in the default case.

To understand the control flow of an if-else statement in Python, take a look at the flow chart of how the execution takes place:

     if expression:
         statement(s)
     else:
         statement(s)

An IF expression is followed by an indented block of statements. If the expression is True: the first block of statements is executed, then the second is skipped.

But, after the IF statement in Python, there is an optional ELSE statements, which is followed by another indented block of statements. When the IF expression is False: the first block of statements is skipped, then, the second executed instead.

There is no limit on the number of statements that can appear under the two clauses of an IF-ELSE statement, but there has to be at least one statement in each block! Either way, execution then resumes after the second block. Also note that both suites of statements are defined by indentation, as described earlier.

Let’s play this video, stick around and watch until the end of this video! 👍🏻

– Digital Academy™ 🎓

***

☞ WATCH NEXT:
○ Data Types in Python – https://youtu.be/cweUByxBWiU
○ Operators in Python – https://youtu.be/-wDaVLkKOiU
○ IF Statements in Python – https://youtu.be/CC5seZ6OBJ4
○ FOR Loops in Python – https://youtu.be/JgH-D5DSTho

☞ WATCH MORE:
○ HOW TO Learn Python? Python Tutorial for Beginners [FULL Course] https://youtu.be/9hvnSZPMtuw

📖 Blog: http://digital.academy.free.fr/blog/

📖 Complete Python Development Course for Beginners [PLAYLIST]: http://digital.academy.free.fr/playlist/python-development-for-beginners

🛒 Shopping and Discounts: http://digital.academy.free.fr/store/

#Python #Tutorial #Beginners #Shorts

***

♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.

***

♡ FOLLOW US ♡
http://digital.academy.free.fr/
https://twitter.com/DigitalAcademyy
https://www.facebook.com/digitalacademyfr
https://www.instagram.com/digital_academy_fr/
https://www.youtube.com/c/DigitalAcademyOnline

♡ SUPPORT US ♡
http://digital.academy.free.fr/join
http://digital.academy.free.fr/donate
http://digital.academy.free.fr/subscribe
https://www.patreon.com/digital_academy
https://www.buymeacoffee.com/digital_academy

***

Copy link
Powered by Social Snap