Find us on Facebook

Thursday, December 13, 2018

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:

Popular Posts

Text Widget

Search This Blog

Powered by Blogger.

Blogger Pages

Like Canvas?

Sponsor

Footer Widgetized Areas

About Canvas

About Canvas

Subscribe Us

About

Text Widget

Tags

Total Pageviews

print pdf

cal

Most Popular

    TUPLES
 LIST and SLICING
      ASCII VALUE
Copyright © KTU Btech Cse Python Lab Manuals | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates