Thursday, September 29, 2011

python functions

#!/usr/bin/python
#Author: Balasubramaniam Natarajan
#Purpose: Demonstrate Function

def add(a,b):
    sum = a+b
    return sum

print "*********Demonstrating Functions***********"
a = input("Enter the first value to be added :")
b = input("Enter the second value to be added :")

addedvalue = add(a,b)

print "The sum of a : ",a," and b : ",b," is = ", addedvalue

#END
 
Output

bala@bala-laptop:~/python$ python function.py
*********Demonstrating Functions***********
Enter the first value to be added :2
Enter the second value to be added :3
The sum of a :  2  and b :  3  is =  5
bala@bala-laptop:~/python$

No comments:

Post a Comment