bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

Python Modules

 

Modules are used to divide the code into the smaller parts. In this you can group the similar data which makes the program easier to understand the code. Module is a file which contains function, variables etc. Modules are processed with two new statements and one important built-in function which are:

  • import – Lets a client obtain a module as a whole.
  • from – Permits clients to fetch particular names from a module
  • reload – Gives a way to reload a code of module without stopping Python

There are some reasons so we use module that are –

  • Code reuse
  • System namespace partitioning
  • Implementing shared services or data

 

Importing a Module:

To import a module import keyword is used.

Syntax 

import <file_name1,file_name2….file_namen>

e.g.

def intellipaat():

print “Hello intellipaat”

save this file as hello.py

import hello

hello.intellipaat()

Output

Hello intellipaat

 

  • form…import is used to import particular attribute from a module.

Syntax

from  module_name import atr1,atr2,...atrn

 

  • To import whole module use following syntax

Syntax 

from module_name import *

 

Built in Modules

Function Description
ceil(n) Returns the next integer number of the given number
sqrt(n) Returns the Square root of the given number.
exp(n) Returns the natural logarithm e raised to the given number
floor(n) Returns the previous integer number of the given number.
log(n,baseto) Returns the natural logarithm of the number.
pow(baseto, exp) Returns baseto raised to the exp power.
sin(n) Returns sine of the given radian.
cos(n) Returns cosine of the given radian.
tan(n) Returns tangent of the given radian.
This blog will help you get a better understanding of Automate Your Coding with Python!

"0 Responses on Python Modules"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 10th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free Python Modules.