+ 2

Can someone tell me what actually modules are,how do you use and make them ?

How do modules work .

23rd Jul 2016, 5:16 AM
Ivan
Ivan - avatar
14 Respuestas
+ 2
As I can see your first half of the question is solved... . Now how to make your own modules? . Make a file named somemodule.py --------------- # this is somemodule.py def greet(name): print "Hello "+name+"!!" --------------- Another file called whatever.py --------------- #this is where you want to import the #previously created module import somemodule name=input('Enter your name : ") greet(name) --------------
27th Jul 2016, 8:20 PM
Prashant Shahi
Prashant Shahi - avatar
+ 2
Ivan.. Check my previous comment... In *whatever.py* section It shows how to import.. . What are modules? - A package or bundle of functions and defined variables by a programmer, such that we don't have to write it all again.. Instead a simple import and call would do the job.. . Now, why to import modules? -Answer is simple.. To use functions and variables from those modules/bundles...
28th Jul 2016, 6:22 AM
Prashant Shahi
Prashant Shahi - avatar
+ 1
Modules - the result of the work of other programmers that you can use in your code. For example, to do heavy mathematical calculations, you will need to connect the math module.
23rd Jul 2016, 8:14 AM
Alexander T.
Alexander T. - avatar
+ 1
hi I am Aakash ....... from India .... actually module is a function to call needed resources from library.. like to call pi from maths... call squateroot from math calling sort.... calling random from library to make a series of random numbers chosen by computer itself... etc .... I hope you understand ....
24th Jul 2016, 5:50 PM
Aakash Sharma
Aakash Sharma - avatar
+ 1
To Aakash: thanks VERY much!! But can you make modules?
26th Jul 2016, 4:54 AM
Ivan
Ivan - avatar
+ 1
Thanks VERY much Shahi!!! everyone please leave a mark up for him ,now I'm left with only three questions here they are : what is importing modules?, How to import modules? and Why import modules?
28th Jul 2016, 3:58 AM
Ivan
Ivan - avatar
+ 1
To:shahi Still don't get it
28th Jul 2016, 6:23 AM
Ivan
Ivan - avatar
+ 1
You know C ? We import/include "math.h" for functions like sqrt,sin,cos,tan,log,etc and some constants like PI,e,etc - stdio.h for printf, scanf, etc . Similarly here we use import module
28th Jul 2016, 6:33 AM
Prashant Shahi
Prashant Shahi - avatar
+ 1
I don't know C
28th Jul 2016, 6:36 AM
Ivan
Ivan - avatar
+ 1
Ok.. . Suppose u need to sort an array.. And u dont know any sorting program logic.. So I'll make a module/bundle having that function within..And pass a copy to u.. . So u'll need to use "import mybundle.py" Then, u'll be able to use sorting function within mybundle and complete your task..
28th Jul 2016, 6:46 AM
Prashant Shahi
Prashant Shahi - avatar
+ 1
To:Shahi THANK YOU VERY MUCH I get it.
28th Jul 2016, 8:21 AM
Ivan
Ivan - avatar
0
Hello Ivan. I'm Ilya
23rd Jul 2016, 8:03 AM
Ilya
0
Hello Ilya I'm Ivan
23rd Jul 2016, 8:05 AM
Ivan
Ivan - avatar
0
If you are Russian, let's move on Russian language.
23rd Jul 2016, 8:16 AM
Alexander T.
Alexander T. - avatar