Skip to main content

Two example Python Modules to use in your project

python modules

In Python writing script is a main task across all the data analytics project. This post tells you how to create sample macros and importing into your python interpreter and process or steps to execute it.

A module is created as a script file, which contains function definitions that can be called in two ways:
  • From the interpreter 
  • From another script file or from another function

How to import

What is process. You can just save the below script as fact.fy

In interpreter...
>>> import fact
>>>fact.factorial(5)
120
# This program illustrates the designing/creation of a module

def factorial(n):
        "This module computes factorial"
        f=1;
        for i in range (1, n+1):
                  f=f*i;
        print(f)
        return 

What is reloading the script

The Python interpreter imports a module only once in a session. If some modifications are performed in the module script then it must be reloaded (imported) again in the interpreter for further use.
A script is reusable component and you can add n number of functions inside of it.

Directory function

In order to see the list of function names defined in a module, Python is provided with a built-in function called dir(). It displays the list of all the function definition names as follows:
>>>dir()


['__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__','__name__', '__package__','__spec__',
'fib']
        

Other way if we give 'module' name in dir(), you will get list of all functions inside of it.
>>>dir(mymodule)

Also read

Comments

Popular posts from this blog

R Vs SAS differences to read today

Statistical analysis should know by every software engineer. R is an open source statistical programming language. SAS is licensed analysis suite for statistics. The two are very much popular in Machine learning and data analytics projects.
SAS is analysis suite software and R is a programming language R ProgrammingR supports both statistical analysis and GraphicsR is an open source project.R is 18th most popular LanguageR packages are written in C, C++, Java, Python and.NetR is popular in Machine learning, data mining and Statistical analysis projects. SASSAS is a statistical analysis suite. Developed to process data sets in mainframe computers.Later developed to support multi-platforms. Like  Mainframe, Windows, and LinuxSAS has multiple products. SAS/ Base is very basic level.SAS is popular in data related projects. Learn SAS vs R Top Differences between SAS Vs R Programming SAS AdvantagesThe data integration from any data source is faster in SAS.The licensed software suite, so you…

Blue Prism complete tutorials download now

Blue prism is an automation tool useful to execute repetitive tasks without human effort. To learn this tool you need the right material. Provided below quick reference materials to understand detailed elements, architecture and creating new bots. Useful if you are a new learner and trying to enter into automation career. The number one and most popular tool in automation is a Blue prism. In this post, I have given references for popular materials and resources so that you can use for your interviews.
RPA Blue Prism RPA blue prism tutorial popular resources I have given in this post. You can download quickly. Learning Blue Prism is a really good option if you are a learner of Robotic process automation.
RPA Advantages The RPA is also called "Robotic Process Automation"- Real advantages are you can automate any business process and you can complete the customer requests in less time.

The Books Available on Blue Prism 
Blue Prism resourcesDavid chappal PDF bookBlue Prism BlogsVi…

Top Differences Read Today Agile vs Waterfall model

The Agile and Waterfall both models are popular in Software development. The Agile model is so flexible compared to waterfall model. Top differences on Waterfall vs Agile give you clear understanding on both the processes. Waterfall ModelThe traditional model is waterfall. It has less flexibility.Expensive and time consuming model.Less scalable to meet the demand of customer requirements.The approach is top down. Starting from requirements one has to finish all the stages, till deployment to complete one cycle.A small change in requirement, one has to follow all the stages till deployment.Waterfall model creates idleness in resource management. Agile ModelAgile model is excellent for rapid deployment of small changesThe small split-requirements you can call them as sprintsLess idleness in resource management.Scope for complete team involvement.Faster delivery makes client happy.You can deploy changes related to compliance or regulatory quickly.Collaboration improves among the team.