Posts

Showing posts from January, 2021

What are modules in Python?

Python Modules  In this article, you will learn to create and import custom modules in Python. Also, you will find different techniques to import and use custom and built-in modules in Python.  Best Python Training Institute in Gurgaon... What are modules in Python?  Modules refer to a file containing Python statements and definitions.  A file containing Python code, for example: example.py, is called a module, and its module name would be an example.  We use modules to break down large programs into small manageable and organized files. Furthermore, modules provide reusability of code.  We can define our most used functions in a module and import it, instead of copying their definitions into different programs.  Let us create a module. Type the following and save it as example.py. # Python Module example  def add(a, b):   """This program adds two   numbers and return the result"""   result = a + b   return ...