Image

Programs - Python - Package

Program:

def welcome(fname, lname):
print("Hello, " +fname)
print("Hello, " +lname)

def login(username,password):
if username==password:
print("You have login successfully")
else:
print("you have entered wrong username and password")

def square(num):
print("square of two no=", num*num)

pi=3.141592653589793

def add(num):
print("addition of two no=", num+num)

# Note: we have save this file with name module1.py in a separate file


# In another file place the below code(module2.py)
import module1 # here we import the saved file to use the functions, it work’s as package

module1.welcome("prashant","jha")
module1.square(2)


Output:

Hello, prashant
Hello, jha
square of two no= 4