Python Fundamentals - Modules in Python

Veröffentlicht am: 01 September 2019
auf dem Kanal: G C Reddy Programming
153
4

https://www.gcreddy.com/python/python...
1. What is Python Module?

.A module is a file consisting of Python code. It can define functions, classes, and variables, and can also include runnable code. Any Python file can be referenced as a module.

.A file containing Python code, for example: test.py, is called a module, and its name would be test..

Module vs. Function

Function: it’s a block of code that you can use/reuse by calling it with a keyword. Eg. print(. is a function.

Module: it’s a .py file that contains a list of functions (it can also contain variables and classes.. Eg. in statistics.mean(a., mean is a function that is found in the statistics module.

2. Purpose of Modules

.As our program grows more in the size we may want to split it into several files for easier maintenance as well as reusability of the code. The solution to this is Modules.

.We can define our most used functions in a module and import it, instead of copying their definitions into different programs. A module can be imported by another program to make use of its functionality. This is how we can use the Python standard library as well.

3. Types of Modules

.Python provides us with some built-in modules, which can be imported by using the "import" keyword.

.Python also allows us to create our own modules and use them in our programs.


Auf dieser Seite können Sie das Online-Video Python Fundamentals - Modules in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer G C Reddy Programming 01 September 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 153 Mal angesehen und es wurde von 4 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!