Difference between revisions of "Calculate days in a month"

From CompSciWiki
Jump to: navigation, search
Line 4: Line 4:
 
===[[if/else/elseif syntax in Python]]===
 
===[[if/else/elseif syntax in Python]]===
  
if(expression):
+
if (expression):
 
   Statement(s)
 
   Statement(s)
elif(expression):
+
elif (expression):
 
   Statement(s)
 
   Statement(s)
 
else:
 
else:

Revision as of 22:14, 3 April 2012

COMP 1010 Home > Back to Extra Labs

Introduction

In this program, you will be taught how to use if and else conditional statements in Python.

if/else/elseif syntax in Python

if (expression):

  Statement(s)

elif (expression):

  Statement(s)

else:

  Statement(s)

As you may have noticed, Python uses elif in place of elseif in Java. Also, Python is a little picky about indentation; hence it is recommended that you use the if, elif and else syntax as shown above.

Step 1:

 Bla9; 

Bla2.