top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Modules in python

Writer's picture: Imene MaallemImene Maallem

A python module can be described as a python program file which contains a python code including python functions, class, or variables. In other words, It can be said that a python code file saved with the extension (.py) is treated as the module. We may have a runnable code inside the python module.

Modules in Python provides us the flexibility to organize the code in a logical way.

To use the functionality of one module into another, we must have to import the specific module. a module in python, is python file with py extension it is like a section of a physical library it contains functions that are related to one another

#We use these modules to break down large program into small manageable and organized files module allows reusability of code. For example

Example

In this example, we will create a module named as file.py which contains a function func that contains a code to print some message on the console.

:


# Function takes in 2 numbers and returns their sum :
def add(x,y):
    Result =x+y
    return(Result)
print(add(5,6))
11



#We can import a module by renaming it as follows:
import math as m
print("the value of pi is" , m.pi)
# We renamed math module as m
the value of pi is 3.141592653589793



#We can also import specific names from module without importing the whole module
from math import pi
print("the value of pi is", pi)
#We imported only the pi attribute from math module
the value of pi is 3.141592653589793



# We can also  import all names from module using this syntax:Import all names from standard
from math import *
print("the value of pi is" , pi)
the value of pi is 3.141592653589793


0 comments

Recent Posts

See All

Commenti


COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page