 Hello everyone, my name is Nikhil Gadjum working as assistant professor in department of computer science and engineering in Valtran Institute of Technology, Solapur. In today's session we will see modules and packages in Python. Learning outcome at the end of this session students will be able to write a Python program using modules and packages in Python. So a Python module can be defined as a Python program file which contains a Python code including Python functions or classes or variables. So whatever variables you write in a Python file whatever classes generally you write whatever functions you write that Python file we generally call it as module. So Python provides two ways to load the module in your program. First one is import statement, second one is the from import statement. First for importing a module which is present in another packages suppose syntax is from package name import a module name. So module is nothing but a Python file you write. Suppose someone has written the other module which you want to use in your program in that case you are importing that module in your program or suppose you have written your own Python file and you want that file while writing another program in another file in that case you need this importing, importing a module. So what is package? Package is nothing but a collection of all the modules we call it as a package. So syntax for importing module is from package name import the module name and using that module name you can call a different or you can access variables functions or a class in Python. We will see an example in PyChomp. Suppose this is my project I will create a package. So right click on this click on new then Python package. Suppose package name is package one. This is my package name so this is the package created inside that package I will create a Python file or Python module. This is a new Python file a file name is suppose file one. So this is my file one which is present in package one. I will write one function here suppose def display or add. Suppose add function I will write and which is accepting two values a and b and then this is result equal to a plus b and then print addition equal to comma result. So this is my file one module I want to use that inside my main.py. Now main.py is my Python file which is present inside this package which is not in package one. Package one is my different package now v and v is my different package. I want to use that file one add function inside that inside this file which is not present inside that package. How to import that module? So this is from package name package name is my package one import your file name. File name is file one. So this is how you are importing a file one module inside your file. Now to call this now this is file one dot add two values I want to pass 10 and 20. Execute this. So it is printing addition equal to 30. So actually add function of file one it is not present inside this file. It is present in another package another file called as file one dot py. I have imported the code of file one inside this main.py using the syntax called as from package one import file one. This is how you are importing modules in Python. We will move forward now. There are many inbuilt modules are present from that inbuilt modules we will see some of the modules. First one is random module. So Python has a inbuilt module that you can use to make the random numbers. So random using random module you can generate the random numbers. How to use that we will see that. So this is import random suppose you print random dot. So these are all the functions which are present in random module. So from that I will use random dot rand int in bracket suppose 0 to 100. If you execute this program it is printing 43. So what this random dot rand int function is doing it is generating a random number between 0 to 100. Every time it will generate a new number. This time it is printing 37. So next time it will print 30 values something like that. So every time a random int function will generate a random number. So random module is used for generating the random numbers. There is another function called as shuffle. How to use that we will see. Suppose I am declaring one list. List 1 equal to suppose 1, 2, 3, 4 and 5 and I am using random dot shuffle. Suppose list 1 equal to this is random dot shuffle in bracket list 1 and I am printing this list 1. I will execute this. So it is shuffling the values all the elements of list 1. So random dot shuffle is another function which is used for shuffling the elements of list 1 or any data that you provide to this function. So this is another useful function in random module. We will see next module called as math module. So all the functions which are related to mathematics generally those are present inside a math module. So Python has inbuilt module that you can use for mathematical task. We will see now. Suppose this is import math and then suppose this is print math dot second math dot. So these are all the functions which are present inside math module. Floor is there, sale is there, then power function is there. There are many functions are there inside this math module. Suppose power function in then I am passing 2 and 5 to execute this it is printing 30. It is generating 2 raise to 5. So power is one of the function which is present in math. Similarly there are many functions are there. Sqrt is another function which is used for finding square root of a value, particular value. So I am passing cost and all these trigonometric functions are there which are also there inside a math module. I will use Sqrt function suppose and I am passing 5. I want to calculate the value square root of 5 to execute this. So it is printing square root of value 5. Similarly sale and floor functions are also there in math module. You can pause the video and you can answer what is the value written by math dot sale in bucket 2.6 and math dot floor in bucket 2.6. You can pause the video and you can answer. So answer for this is math dot sale in bucket 2.6. So sale value is calculating next integer value or return the next integer value and math dot floor function will return the previous integer value. You can check this, suppose this is math dot sale, this is 2.6 and then math dot floor and again 2.6. If you execute this it is printing value 3 and 2. So these are again two useful functions in during your program. So sale function generally used to find out next integer value. It doesn't check the value whether that value is more than 0.5 value or less than 0.5 value. It doesn't matter. If you write math dot sale 2.1 and math dot floor 2.1 and if you execute this it is printing 3 and 2. So it doesn't check whether point value is more than 0.5 or less than 0.5 doesn't matter for sale or floor function. Generally sale function is used to calculate the next integer value to find out the next integer value. Floor function is used to find out the previous integer value. These are the references I have used for creation of this video. Thank you.