Learn Python Episode #21: If, Elif, Else Statements

Get The Learn to Code Course Bundle!
https://josephdelgadillo.com/product/learn-to-code-course-bundle/

Enroll in The Complete Python Course on Udemy!
https://www.udemy.com/python-complete/?couponCode=PYTHONWP

In this tutorial we are going to be learning about the conditional statements available to you in Python. So, we’re going to be learning about the if-else statement, and this is basically provides us a way to evaluate if something is true or false, and then perform something whether or not the condition is met. Let’s write an if-else statement.

check = True

if check == False:
print("It is false")
else:
print("It is actually equal to True")

This is going to print out “It is actually equal to True” in the console. First, Python is going to check if the variable is equal to false. Else, it’s going to continue through the script and print, or perform, whatever we tell it to do. This is great if we only have two conditions, but what if we want to use more than two? Between the if and else we can use an elif statement, and here we can supply an additional condition.

check = Hamburger

if check == False:
print(“It is false”)
elif check == “Hamburger”:
print(“Yummm, hamburgers”)
else:
print(“It is actually equal to True”)

When we run this script it’s going check to see if the first condition is true, if not it will check the next condition, if not it will print the else statement. So, that’s what an if-statement is, and these are necessary for the project we are about to begin working on.

Web – https://josephdelgadillo.com/
Subscribe – https://goo.gl/tkaGgy
Follow for Updates – https://steemit.com/@jo3potato

3 thoughts on “Learn Python Episode #21: If, Elif, Else Statements

  • November 7, 2018 at 10:47 pm
    Permalink

    Very interesting points you have remarked, appreciate it for putting up.

  • December 28, 2018 at 5:29 pm
    Permalink

    Write more, thats all I have to say. Literally, it seems as though you relied
    on the video to make your point. You definitely know what youre talking about, why throw away your
    intelligence on just posting videos to your site
    when you could be giving us something enlightening to read?

  • January 5, 2019 at 2:41 am
    Permalink

    Thanks to my father who shared with me regarding this blog, this webpage is
    really awesome.

Comments are closed.