Page 138 - 2622_Delhi Police Public School_C-8
P. 138

Program 13: To add two numbers using function.

                   Program13.py
                File  Edit  Format   Run   Options   Window    Help

                def add(a, b):
                    sum = a * b
                    return sum
                numl = int(input("Enter first number: "))
                num2 = int(input("Enter second number: "))
                print("The sum is",add(numl,num2))




              On running the above program, you will get the following output:

                   Output

                Enter first number: 5
                Enter second number: 6
                The sum is 11




              Program 14: To find the product of two numbers using function.


                   Program14.py
                File  Edit  Format   Run   Options   Window    Help


                def prod(a, b):
                    multi = a * b
                    return multi
                numl = int(input("Enter first number: "))
                num2 = int(input("Enter second number: "))
                print("The product is",prod(numl,num2))





              On running the above program, you will get the following output:

                   Output

                Enter first number: 5
                Enter second number: 4
                The sum is 20













                        Premium Edition-VIII
                136
   133   134   135   136   137   138   139   140   141   142   143