Add 2 numbers using function
Aim: Implement
a program to add 2 numbers using functions.
Algorithm:
1.Start
2.Input 2 numbers
3.Call add(a,b)
4.print sum
5.stop
Function
add()
1.Start
2 return a+b
3.stop
Program:
def add(a,b):
return a + b
print "The first
number you want to add?"
a = input("First
no: ")
print "What's the
second number you want to add?"
b = input("Second
no: ")
result = add(a, b)
print "The result
is”,result
Output:
The first number you
want to add? 2
What's the second
number you want to add? 3
The
result is:5
0 Comments:
Post a Comment