<

Watch Python Programming: If Statements

Posted on
13,112 Points
512 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:22
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
This article will show a step by step guide on how use Break in Python
In this article, we will discuss the new features which are introduced into the Angular 6 version.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month