SlideShare a Scribd company logo
Computer Science
Class XI ( As per CBSE Board)
Chapter 15
Python
Modules
Visit : python.mykvs.in for regular updates
Termwise
Syllabus
2021-22
Python Module
A module is a logical organization of
Python code. Related code are
grouped into a module which makes
the code easier to understand and
use. Any python module is an object
with different attributes which can
be bind and referenced.
Simply, it is a file containing a set of
functions which can be included in
our application.
Python provide inbuilt standard
modules, like math, random etc.
Visit : python.mykvs.in for regular updates
import - Python modules can get access to code from another
module by importing the file/function using import.
import math
print(math.pi)
from - pi as a whole can be imported into our initial code, rather
than importing the whole module.
from math import pi
print(pi)
In the above code module, math is not imported, rather just pi has
been imported as a variable.
All the functions and constants can be imported using *.
from module_name import *
print(pi)
print(factorial(6))
Python Module
Visit : python.mykvs.in for regular updates
math module
The math module is a standard module in Python
and is always available. To use mathematical
functions under this module, we have to import
the module using import math statement.
How to use math function
import math
math.sqrt(4)
Python Module
Visit : python.mykvs.in for regular updates
math.sqrt()
The math.sqrt() method returns the square root of a given number.
>>>math.sqrt(100)
10.0
>>>math.sqrt(3)
1.7320508075688772
The ceil() function approximates the given number to the smallest integer,
greater than or equal to the given floating point number. The floor() function
returns the largest integer less than or equal to the given number.
>>>math.ceil(4.5867)
5
>>>math.floor(4.5687)
4
math.pow()
The math.pow() method receives two float arguments, raises the first to the
second and returns the result. In other words, pow(2,3) is equivalent to 2**3.
>>>math.pow(2,4)
16.0
Python Module
Visit : python.mykvs.in for regular updates
math.fabs()
Returns the absolute value of x
>>> import math
>>> math.fabs(-5.5)
5.5
The math module contains functions for calculating various
trigonometric ratios for a given angle. The functions (sin, cos, tan,
etc.) need the angle in radians as an argument.
>>> math.sin(270)
-0.1760459464712114
Python Module
Visit : python.mykvs.in for regular updates
Random Module
The random module provides access to functions that support many
operations.Perhaps the most important thing is that it allows us to
generate random numbers.
random.randint()
Randint accepts two parameters: a lowest and a highest number.
import random
print (random.randint(0, 5))
This will output either 1, 2, 3, 4 or 5.
random.random()
Genereate random number from 0.01 to 1.If we want a larger
number, we can multiply it.
import random
print(random.random() * 100)
Python Module
Visit : python.mykvs.in for regular updates
randrange()
generate random numbers from a specified range and also allowing rooms for steps to be
included.
Syntax :
random.randrange(start(opt),stop,step(opt))
import random
# Using randrange() to generate numbers from 0-100
print ("Random number from 0-100 is : ",end="")
print (random.randrange(100))
# Using randrange() to generate numbers from 50-100
print ("Random number from 50-100 is : ",end="")
print (random.randrange(50,100))
# Using randrange() to generate numbers from 50-100
# skipping 5
print ("Random number from 50-100 skip 5 is : ",end="")
print (random.randrange(50,100,5))
OUTPUT
Random number from 0-100 is : 27
Random number from 50-100 is : 48
Random number from 50-100 skip 5 is : 80
Python Module
Visit : python.mykvs.in for regular updates
statistics module
This module provides functions for calculating mathematical statistics of numeric (Real-
valued) data.
statistics.mean(data)
Return the sample arithmetic mean of data which can be a sequence or iterator.The
arithmetic mean is the sum of the data divided by the number of data points(AVERAGE).
import statistics
print(statistics.mean([5,3,2]))
OUTPUT
3.3333333333333335
statistics.median(data)
Return the median (middle value) of numeric data, using the common “mean of middle
two” method. If data is empty, StatisticsError is raised.
import statistics
print(statistics.median([5,5,4,4,3,3,2,2]))
OUTPUT
3.5
Python Module
Visit : python.mykvs.in for regular updates
statistics.mode(data)
Return the most common data point from discrete or nominal data. The mode (when it
exists) is the most typical value, and is a robust measure of central location.If data is
empty, or if there is not exactly one most common value, StatisticsError is raised.
import statistics
print(statistics.mode([1, 1, 2, 3, 3, 3, 3, 4]))
OUTPUT
3
Python Module
Visit : python.mykvs.in for regular updates

More Related Content

Similar to python modules1522.pdf

Objects and Graphics
Objects and GraphicsObjects and Graphics
Objects and Graphics
Edwin Flórez Gómez
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
vishnupriyapm4
 
Chapter04.pptx
Chapter04.pptxChapter04.pptx
Chapter04.pptx
GiannisPagges
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
georgejustymirobi1
 
Data Handling.pdf
Data Handling.pdfData Handling.pdf
Data Handling.pdf
MILANOP1
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
ARVIND PANDE
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
Inzamam Baig
 
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptxCLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
seccoordpal
 
Modules in Python.docx
Modules in Python.docxModules in Python.docx
Modules in Python.docx
manohar25689
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
Intro C# Book
 
17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf
JeevithaG22
 
sql functions3.pdf about the function of sql
sql functions3.pdf about the function of sqlsql functions3.pdf about the function of sql
sql functions3.pdf about the function of sql
mahakgodwani2555
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
Functions2.pptx
Functions2.pptxFunctions2.pptx
Functions2.pptx
AkhilTyagi42
 
Functions.docx
Functions.docxFunctions.docx
Functions.docx
VandanaGoyal21
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
CBJWorld
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
Dan Bowen
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
argusacademy
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdf
Usha570012
 

Similar to python modules1522.pdf (20)

Objects and Graphics
Objects and GraphicsObjects and Graphics
Objects and Graphics
 
Unit 2function in python.pptx
Unit 2function in python.pptxUnit 2function in python.pptx
Unit 2function in python.pptx
 
Chapter04.pptx
Chapter04.pptxChapter04.pptx
Chapter04.pptx
 
PYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptxPYTHON-PROGRAMMING-UNIT-II (1).pptx
PYTHON-PROGRAMMING-UNIT-II (1).pptx
 
Data Handling.pdf
Data Handling.pdfData Handling.pdf
Data Handling.pdf
 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptxCLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
CLASS-11 & 12 ICT PPT PYTHON PROGRAMMING.pptx
 
Modules in Python.docx
Modules in Python.docxModules in Python.docx
Modules in Python.docx
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf17 PYTHON MODULES-2.pdf
17 PYTHON MODULES-2.pdf
 
sql functions3.pdf about the function of sql
sql functions3.pdf about the function of sqlsql functions3.pdf about the function of sql
sql functions3.pdf about the function of sql
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Functions2.pptx
Functions2.pptxFunctions2.pptx
Functions2.pptx
 
Functions.docx
Functions.docxFunctions.docx
Functions.docx
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
sql functions3 (1).pdf
sql functions3 (1).pdfsql functions3 (1).pdf
sql functions3 (1).pdf
 

Recently uploaded

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 

Recently uploaded (20)

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 

python modules1522.pdf

  • 1. Computer Science Class XI ( As per CBSE Board) Chapter 15 Python Modules Visit : python.mykvs.in for regular updates Termwise Syllabus 2021-22
  • 2. Python Module A module is a logical organization of Python code. Related code are grouped into a module which makes the code easier to understand and use. Any python module is an object with different attributes which can be bind and referenced. Simply, it is a file containing a set of functions which can be included in our application. Python provide inbuilt standard modules, like math, random etc. Visit : python.mykvs.in for regular updates
  • 3. import - Python modules can get access to code from another module by importing the file/function using import. import math print(math.pi) from - pi as a whole can be imported into our initial code, rather than importing the whole module. from math import pi print(pi) In the above code module, math is not imported, rather just pi has been imported as a variable. All the functions and constants can be imported using *. from module_name import * print(pi) print(factorial(6)) Python Module Visit : python.mykvs.in for regular updates
  • 4. math module The math module is a standard module in Python and is always available. To use mathematical functions under this module, we have to import the module using import math statement. How to use math function import math math.sqrt(4) Python Module Visit : python.mykvs.in for regular updates
  • 5. math.sqrt() The math.sqrt() method returns the square root of a given number. >>>math.sqrt(100) 10.0 >>>math.sqrt(3) 1.7320508075688772 The ceil() function approximates the given number to the smallest integer, greater than or equal to the given floating point number. The floor() function returns the largest integer less than or equal to the given number. >>>math.ceil(4.5867) 5 >>>math.floor(4.5687) 4 math.pow() The math.pow() method receives two float arguments, raises the first to the second and returns the result. In other words, pow(2,3) is equivalent to 2**3. >>>math.pow(2,4) 16.0 Python Module Visit : python.mykvs.in for regular updates
  • 6. math.fabs() Returns the absolute value of x >>> import math >>> math.fabs(-5.5) 5.5 The math module contains functions for calculating various trigonometric ratios for a given angle. The functions (sin, cos, tan, etc.) need the angle in radians as an argument. >>> math.sin(270) -0.1760459464712114 Python Module Visit : python.mykvs.in for regular updates
  • 7. Random Module The random module provides access to functions that support many operations.Perhaps the most important thing is that it allows us to generate random numbers. random.randint() Randint accepts two parameters: a lowest and a highest number. import random print (random.randint(0, 5)) This will output either 1, 2, 3, 4 or 5. random.random() Genereate random number from 0.01 to 1.If we want a larger number, we can multiply it. import random print(random.random() * 100) Python Module Visit : python.mykvs.in for regular updates
  • 8. randrange() generate random numbers from a specified range and also allowing rooms for steps to be included. Syntax : random.randrange(start(opt),stop,step(opt)) import random # Using randrange() to generate numbers from 0-100 print ("Random number from 0-100 is : ",end="") print (random.randrange(100)) # Using randrange() to generate numbers from 50-100 print ("Random number from 50-100 is : ",end="") print (random.randrange(50,100)) # Using randrange() to generate numbers from 50-100 # skipping 5 print ("Random number from 50-100 skip 5 is : ",end="") print (random.randrange(50,100,5)) OUTPUT Random number from 0-100 is : 27 Random number from 50-100 is : 48 Random number from 50-100 skip 5 is : 80 Python Module Visit : python.mykvs.in for regular updates
  • 9. statistics module This module provides functions for calculating mathematical statistics of numeric (Real- valued) data. statistics.mean(data) Return the sample arithmetic mean of data which can be a sequence or iterator.The arithmetic mean is the sum of the data divided by the number of data points(AVERAGE). import statistics print(statistics.mean([5,3,2])) OUTPUT 3.3333333333333335 statistics.median(data) Return the median (middle value) of numeric data, using the common “mean of middle two” method. If data is empty, StatisticsError is raised. import statistics print(statistics.median([5,5,4,4,3,3,2,2])) OUTPUT 3.5 Python Module Visit : python.mykvs.in for regular updates
  • 10. statistics.mode(data) Return the most common data point from discrete or nominal data. The mode (when it exists) is the most typical value, and is a robust measure of central location.If data is empty, or if there is not exactly one most common value, StatisticsError is raised. import statistics print(statistics.mode([1, 1, 2, 3, 3, 3, 3, 4])) OUTPUT 3 Python Module Visit : python.mykvs.in for regular updates