Learn Python E4: If, Elif, Else | Eagle Rare

Published: 01 January 1970
on channel: tipsy_python
30
3

Watch examples of if/elif/else conditional statements in Python. Learn how to use conditional statements to create logical program flows for your Python applications.

Season 1 - Episode 4 | Featuring: Eagle Rare 10 Year Bourbon Whiskey

Conditional statements in Python are built on the boolean (True/False) data type. If statements start by performing an evaluation - if the expression evaluates to True, than a block of code (indented) is executed. In this video I will talk through some of the comparison operators in Python that we use to perform conditional expressions: greater-than, less than, equal-to, greater-than-or-equal, less-than-or-equal, not-equal. Alternatives to truth-test objects using "truthy" attributes in Python. We will also review and demonstrate membership tests to see if an object is in a collection.

We will also consider the supplemental clauses to the if statement that help provide alternative logic. The else clause provide a mutually exclusive piece of logic that is executing when the if-statement is not executed. The elif keyword is another if statement that goes between the "if" and "else" clauses of an if-statement; elif is a shortcut for "else if" in Python. An if-statement can have multiple elif statements to catch multiple cases, followed by an else to catch any unhandled cases. The while-loop is briefly discussed as a loop that executes as long as the expression in the loop definition evaluates to True.

At the conclusion of this video, we enhance the sales tax calculator by adding a conditional statement that allows the user to be prompted to select an option that triggers one of multiple functional options. This allows our practice sales-tax python app to prompt the user to enter an item, view the price history, or exit the app.

Conditional statements are an important addition to your Python skill-set; logical flows are the cornerstone of programming.


Source Code on Github: https://github.com/joshah-moors/tipsy...

I hope you find these videos helpful, and I look forward to interacting with you in the comments~


On this page of the site you can watch the video online Learn Python E4: If, Elif, Else | Eagle Rare with a duration of hours minute second in good quality, which was uploaded by the user tipsy_python 01 January 1970, share the link with friends and acquaintances, this video has already been watched 30 times on youtube and it was liked by 3 viewers. Enjoy your viewing!