Q. Create a package as per following:


mailsys/
|--__init__.py
|-- deliver.py #contains function send mail(), get_mail(), draft(), outbox(), inbox()
|__archive
         |--__init__.py
         |--Oldmail.py # contains functions fiveyr(), starred()


After creation, this should be importable in a program with import statement. It should also have proper docstring so that help() function gives proper information about it.


(a) Complete code of delivery.py (make assumptions)
(b) Complete code of oldmail.py (make assumptions)
(c) Write command to display details of module delivery
(d) Write command to import get_mail() function
(e) Write command to import these modules: deliver and oldmail
(f) Write command to run draft() function
(g) Write command to run fiveyr() function


Answer :-


(a)

Assumed Code :-

def send_mail():
      """This is Send Mail function"""
      return "You used send_mail function."

def get_mail():
      """This is Get Mail function"""
      return "You used get_mail function."

def draft():
      """This is Draft function"""
      return "You used draft function."

def outbox():
      """This is Outbox function"""
      return "You used outbox function."

def inbox():
      """This is Inbox function"""
      return "You used inbox function."

(b)

Assumed Code :-

def fiveyr():
      """This is Fiveyr function"""
      return "You used fiveyr function."

def starred():
      """This is Starred function"""
      return "You used starred function."

(c)

>>> import mailsys.deliver
>>> help ("mailsys.deliver")
Help on module mailsys.deliver in mailsys:
NAME
    mailsys.deliver
FUNCTIONS
    draft()
        This is Draft function
    
    get_mail()
        This is Get Mail function
    
    inbox()
        This is Inbox function
    
    outbox()
        This is Outbox function
    
    send_mail()
        This is Send Mail function
FILE
    c:\users\p w\desktop\mailsys\deliver.py

>>> 

(d)

>>> import mailsys.deliver
>>> mailsys.deliver.get_mail()
'You used get_mail function.'
>>> 


(e)

To import deliver module :-

>>> import mailsys.deliver

To import oldmail module :-

>>> import mailsys.archive.Oldmail


(f) Code :-

>>> import mailsys.deliver
>>> mailsys.deliver.draft()
'You used draft function.'
>>> 

(g) Code :-

>>> import mailsys.archive.Oldmail
>>> mailsys.archive.Oldmail.fiveyr()
'You used fiveyr function.'
>>> 

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post