<

Python Programming: If Statements

Posted on
13,166 Points
566 Views
6 Endorsements
Last Modified:
Community Pick: Many members of our community have endorsed this article.
Editor's Choice: This article has been selected by our editors as an exceptional contribution.
Experience Level: Beginner
2:21
Learn the basics of if, else, and elif statements in Python 2.7.

Video Steps

1. Use "if" statements to test a specified condition.


The structure of an if statement is as follows:
if <condition>:         
           do something

Open in new window

2. Use "else" statements to allow the execution of an alternative, if the first condition is not met


The structure of an if, else statement is as follows:
if <condition>:
         do something     
else:
         do something different

Open in new window

3. Use "elif" statements allow for the checking of multiple conditions.


The structure of an if, else, elif statement is as follows:    
if <condition>:
         do something     
elif <another condition>:
         do something different     
else:
         do something completely different

Open in new window

6
Author:Dototot
0 Comments
In this article, we will discuss how to start development in Angular 6.
This is my 100th publication at EE — 56 articles and 44 videos. To mark the occasion, I wrote a program to download the Title, Views, Endorsements, and Points for the specified URLs of articles and videos. Based on feedback, I enhanced the program t…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month