0% found this document useful (0 votes)
6 views27 pages

Importing Python Modules Guide

The document provides an overview of importing Python modules, including the syntax for using the import statement and module aliasing. It details various functions from the random, statistics, and math modules, explaining their usage and examples. Key functions such as random(), mean(), and sqrt() are highlighted, along with their specific functionalities.

Uploaded by

rahimmnafeesa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views27 pages

Importing Python Modules Guide

The document provides an overview of importing Python modules, including the syntax for using the import statement and module aliasing. It details various functions from the random, statistics, and math modules, explaining their usage and examples. Key functions such as random(), mean(), and sqrt() are highlighted, along with their specific functionalities.

Uploaded by

rahimmnafeesa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

IMPORTING PYTHON Jazeel Cmd

MODULES
INTRODUCTION
Module : A module is a file containing python definition,
functions, variables, classes and statements. The extension
of file “.py”.
IMPORTING PYTHON
MODULES
Using import statement Using from statement
Import <module_name> Used to access specific/all
attributes from a module.
To access a particular method
from any module From<module>import<funct
ion name>
[Link]()
Or from <module>import*
To access a particular method
from any module
Functionname()
MODULE ALIASING
Renaming the module at the time of import, using as
keyword
impot <module name> as <alias name>
random module in python

random()
randrange()
randint()
INTRODUCTION

To use random functions. We


have to import random
module
random()

This generates floating value


between 0 and 1 (including 0 but
excluding 1). It does not require
any argument

[0,1)
randrange()

This method always returns as


integer between lower and upper
limit to this method (excluding
upper limit)
[Link](a,b,stepvalue)
It will generates integer values
within the range a to b (including
a and excluding b ) having
different as step value
randint()
This method takes 2 parameters a,b in which first
one is lower and second is upper limit.
This function returns any integer numbers between
the two numbers, including both limits
EG:
import random
[Link]()
[Link](2,8,2)
[Link](2,5)
statistics module in python

mean()
median()
mode()
IMPORTING STATISTICS
MODULE
It can be included in the program by
using the following statement:
import statistics
mean()

This function returns the Arithmetic


mean (average) of data.
[Link]([2,4,5,6])
median()

This function returns the median


(middle value) of data

[Link](L)
mode()

This function returns the mode (the most


repeated value).

[Link](L)
math module
It contains different types of
mathematical functions. Most of the
functions in this module returns a
float value.
It can be included in the program by
using the statement
import math
sqrt()
To find square root of a number.
[Link](100)
ceil(x)
It returns the biggest integer not
less than x.
X may be an integer or floating-point
number
[Link](5.2)
[Link](5)
[Link](-5.6)
floor()
It returns the smallest integer not less than x.

[Link](-4.5)
[Link](4.5)
[Link](4)
POW()
It returns the value of x**y (x raised to the
power y)
x,y may be an integer of floating point
numbers.
DIFFERENCE BTW POW()
AND [Link]()
pow(x,y,z) - p**y%z
[Link](x,y) - p**y
fabs(x)
[Link](6.7)
[Link](-6.7)
[Link](-4)
degrees()
It converts angle x from radians to degrees
X must be numeric value
[Link]
The [Link] constant returns the value of PI
sin(x)
IT RETURNS THE SINE OF X IN RADIANS.
X MAY BE AN INTEGER OR FLOATING-POINT NUMBER IN RADIANS
[Link](0)

You might also like