Monthly Archives: May 2017

Python- The Decisions

  IF..ELSE

  1. We will start with the simple if..else statement in Python.
  2.  Create a new file ifelse.py and enter the below lines:num = 100
    if (num == 100) : print(“Value of the number is 100”)
    else :
    print (“Value of the number is not equal to 100”)print(“Exit”)                          
  3. Save the file and under Run menu, click on Run module. You should get the output as shown below:

 

All in One

  1. Next, we will see how to use the if, elif and else statements in one program.
  2. Type the code snippet as given below:

          

      3. Save the file and under Run menu, click on Run module. You should get the output as shown below: