Jan 2, 2013

Chapter 16 - Python Functions


 


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 16 - Functions \n------------------------------------\n"


 


def sum_mul(a,b):


 return a+b,a*b


 


c,d = sum_mul(10,20)


 


print "Sum = %d and Product = %d" %(c,d) 


 


print"----------------------------------------"


 


#END





 


Step 2


 


Change file permission to executable using chmod command.


 


Step 3


 


Execute the python file.


 


python-math-function-2



 




 

No comments:

Post a Comment