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

10 Tricky Interview Questions On Storm

Storm is real time computation system. It is a flagship software from Apache foundation. Has the capability to process in stream data. Storm is capable to integrate traditional databases. The list given below are tricky and highly useful for your next interview.
Bench mark for Storm is a million tuples processed per second per node. Tricky Interview Questions1) Real uses of Storm?

A) You can use in realtime analytics, online machine learning, continuous computation, distributed RPC, ETL

2) What are different availble layers on Storm?
FluxSQLStreams APITrident3)  Real use of SQL API on top of Storm?
A) You can run SQL queries on stream data
4) Most popular integrations to Storm? HDFSCassandraJDBCHIVEHBase 5) What are different possible Containers integration with Storm? YARNDOCKERMESOS6) What is Local Mode?

A) Running topologies in Local server we can say as Local Mode.

7) Where all the Events Stored in Storm?
A) Event Logger mechanism saves all events

8) What are Serializable data types in …

Blue Prism complete tutorials download now

Blueprsim is an automation tool useful to execute repetitive tasks without human effort. To learn this tool you need 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 Blue prism. In this post I have given references for popular materials and resources, so that you can use for your interviews.
Why You Need to Learn RPA blue prsim tutorial popular resources I have given in this post. You can download quickly. Learning Blue Prism is really good option if you are 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 BlogsVideo…

Blockchain Smart contract behind mechanism you need to learn quickly

Smart contract in Blockchain is a kind of software application that works without human intervention based on the transaction logs and provide solution to user request. I want to share the back end mechanism in Smart Contract of Blockchain. Smart Contract Mechanism What is Smart ContractA smart contract is a protocol which can auto execute, facilitate, verify or enforce the negotiation of a contract.Agreement between two parties you can say as a contract.Incorporating the rules of physical contract into computing world, you can say as smart contractBlockchain supports you to create smart contracts.Smart Contracts are self-executing programs which run on the blockchain and are capable of enforcing rulesUsing Blockchain as platform and making an agreement or contract between more than two parties, you can say as Smart Contract.Traditional Markets  4 Top Benefits of Smart ContractCurrently smart contracts are being used only in Crypto CurrenciesNow Smart Contracts being used in all financ…