<

Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

Python Programming: If Statements

Posted on
13,008 Points
408 Views
6 Endorsements
Last Modified:
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
Comment
Author:Dototot
0 Comments

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Join & Write a Comment

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month