Chapter 9 – Python Conditionals

 
Step 1
 
Open any text editor (gedit,pico,vi,nano) then enter the following python script and save the file with .py extension.
 
#!/usr/bin/python
#Author : Jijo K Jose
 
print "\n————————————\nChapter 9 – Conditionals \n————————————\n"
 
a = input("Enter integer A : ")
b = input("Enter integer B : ")
if a == b:
 print "A and B are same"
elif a < b:
 print "B is larger"
else:
 print "A is larger"
 
print "\n————————————–\n"
 
#END

 
Step 2
 
Change file permission to executable using chmod command.
 
Step 3
 
Execute the python file.

 

python-conditionals-9
 

 
You can leave a response, or trackback from your own site.

Leave a Reply