What is a Module in Python
![what is a module in python](https://pythonpoint.net/wp-content/uploads/2020/12/what-is-a-module-in-python-1024x576.jpg)
A Module can be defined as a file containing some Python definitions and statements. The module name is the same as the file name (the file name is suffixed with .py
). Within a module, the module’s name (as a string) is available as the value of the global variable __name__
.
You can create modules on your own. For example, let’s create a module which upon calling returns the factorial of a number. This file is named as test.py.
def fact(n): if n==1: return n else: return (n*fact(n-1))
![](https://pythonpoint.net/wp-content/uploads/2020/12/Screenshot-2020-12-06-121732.jpg)
Similarly, we can define as many modules as you need. There are a lot of built-in modules in Python.
Subscribe
Login
Please login to comment
0 Discussion