In this Python for beginners tutorial we are going to learn the following:
How to create a Python module.
How to use a Python module.
In the previous videos, we learned how to create our own functions.
In this example program, we have a function that we created in a previous video that greets the user by his or her name. We also have the add function that calculates and returns the sum of two numbers and a function that returns the name of a given month.
At the beginning of our program, we have the function definitions and then we use these functions by calling them a few times each. As you can see when I hit the run button, the program works and prints out some messages.
As our programs becomes bigger, it becomes harder to follow what is happening. So, to make our code more readable, we are going to move our function definitions into a separate file, a module. So, the first thing we need to do is to create a new file. To create a new file, we have to click on this button, and then this button to create a new file. Let’s name the new file we are going to create my_module.py. The name of the file, is the name of the module.
#pythoncourse #pythontutorial #programmingwithnick
Смотрите видео Create a Module - Python for Absolute Beginners Course онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Programming With Nick 23 Июнь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 336 раз и оно понравилось 21 людям.