In this post, we will create a module lengthconversion.py that stores functions for various lengths conversion functions.

·    miletokm()     to convert miles to kilometers

·   kmtomile()     to convert kilometers to miles

·   feettoinches()

·   inchestofeet() 

It should also store constant values such as value of (mile in kilometers and vice versa).
[I mile = 1.609344 kilometer ; 1 feet = 12 inches] 
Help( ) function should display proper information.

We will write code for all these length conversion functions and store them in lengthconversion.py file. To create user defined function, def keyword can be used. So first we will open python focus editor and write code for this.

Below is implementation of source code

lengthconversion.py

Now, we will import this module by using import statement . Just open the python shell and type following statements

How to find details of user defined modules?

We can easily find all information of imported module by simply typing help() in focus shell of python

It tell us details information about imported module like function name,functions definitions present in modules,variables or data. It also provides details file path of imported module

Related Python Assignments

<

Leave a Reply

Your email address will not be published.