how to call your method for package in the program

Write a program for writing your own addition module in Python and also write code for how to call your method for package in the program.

Step1: Create own function file and save as userfilefunctions.py

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

def sub(a, b):
    return a-b

def multi(a, b):
    return a*b

def div(a, b):
    return a/b

Step2: Implement userfilefunctions.py module in other program save implement.py

from userfilefunctions import *

print(sum(5, 7))
print(sub(10, 5))
print(multi(10, 7))
print(div(9, 3))

Out put: 
12
5
70
3.0

No comments:

Post a Comment

INSTAGRAM FEED

@Python forest