<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC4%2FUsing-Python-Modules%2FEnglish-timed</id>
		<title>Python-3.4.3/C4/Using-Python-Modules/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC4%2FUsing-Python-Modules%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Using-Python-Modules/English-timed&amp;action=history"/>
		<updated>2026-04-19T02:22:49Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Using-Python-Modules/English-timed&amp;diff=47716&amp;oldid=prev</id>
		<title>Pratik kamble: Created page with &quot;{| border=1 | '''Time''' |'''Narration'''  |- | 00:01 | Welcome to the spoken tutorial on '''Using Python Modules'''.   |- |00:06  |In this tutorial, you will learn to-   Exec...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Using-Python-Modules/English-timed&amp;diff=47716&amp;oldid=prev"/>
				<updated>2019-06-10T10:13:18Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| border=1 | &amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039; |&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;  |- | 00:01 | Welcome to the spoken tutorial on &amp;#039;&amp;#039;&amp;#039;Using Python Modules&amp;#039;&amp;#039;&amp;#039;.   |- |00:06  |In this tutorial, you will learn to-   Exec...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
| '''Time'''&lt;br /&gt;
|'''Narration'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:01&lt;br /&gt;
| Welcome to the spoken tutorial on '''Using Python Modules'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:06 &lt;br /&gt;
|In this tutorial, you will learn to- &lt;br /&gt;
&lt;br /&gt;
Execute '''Python scripts''' from '''command line'''&lt;br /&gt;
&lt;br /&gt;
Use '''import''' in '''scripts '''and&lt;br /&gt;
&lt;br /&gt;
Import '''numpy '''and''' matplotlib.pyplot modules'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:22&lt;br /&gt;
|To record this tutorial, I am using &lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 16.04''' operating system&lt;br /&gt;
&lt;br /&gt;
'''Python 3.4.3'''&lt;br /&gt;
&lt;br /&gt;
'''IPython 5.1.0 '''and&lt;br /&gt;
&lt;br /&gt;
'''Gedit text editor'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:40 &lt;br /&gt;
|To practise this tutorial, you should know how to &lt;br /&gt;
&lt;br /&gt;
Use '''plot''' interactively&lt;br /&gt;
&lt;br /&gt;
Embellish and save a '''plot'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:50 &lt;br /&gt;
|If not, see the relevant '''Python''' tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:55&lt;br /&gt;
| First we will learn what is a '''module'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:58&lt;br /&gt;
| A '''module''' is a file containing '''Python definitions''' and '''statements'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:04&lt;br /&gt;
|'''Modules''' are used to break down large programs into small manageable and organized files.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:12&lt;br /&gt;
| '''Definitions''' from a '''module''' can be '''imported''' into other '''modules''' or to the '''main module'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:19 &lt;br /&gt;
|Now let us see how to run a '''Python script''' from '''command line'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:24&lt;br /&gt;
| Open any '''text editor''' and type,  '''print''''' inside brackets inside double quotes '''''Hello World'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:33 &lt;br /&gt;
| We have created a simple '''Python script''' to print '''Hello World'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:38 &lt;br /&gt;
|Save this '''script''' as '''hello.py''' in the current '''working directory'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:44&lt;br /&gt;
|Now let us open the '''terminal.'''&lt;br /&gt;
&lt;br /&gt;
Then navigate to the '''directory''' where '''hello.py''' is saved.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:52&lt;br /&gt;
| Now type, '''python3 hello.py''' and press '''Enter'''.&lt;br /&gt;
It executes the '''script''' and gives the output as '''Hello World.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:04&lt;br /&gt;
| From here onwards, remember to press the '''Enter''' key after typing every '''command''' on the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:11&lt;br /&gt;
| Next we will see how to '''import modules''' and use them in '''Python scripts.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:17&lt;br /&gt;
|Let me open the file''' four''''' underscore '''''plot.py''' in the '''text editor.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:23 &lt;br /&gt;
|This file is available in the '''Code files '''link of this tutorial. You can download and use it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:31&lt;br /&gt;
| This '''code''' will '''plot''' for '''x, -x, sin of x '''and''' xsin of x'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:38 &lt;br /&gt;
| When we '''run''' this '''code''', we will see the final '''plot''' as shown here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:43&lt;br /&gt;
| Now let us '''run''' the file '''four '''''underscore''''' plot.py''' as a '''Python script'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:49 &lt;br /&gt;
| Type, '''python3''' '''four '''''underscore''''' plot.py''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:55&lt;br /&gt;
|It gives an error '''linspace()''' is not defined.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:59&lt;br /&gt;
| It means that, '''function linspace()''' is not available in the current '''namespace'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:05&lt;br /&gt;
| A '''namespace''' is a system for making all the names in a program to be unique.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:11 &lt;br /&gt;
| Let us go back to the file''' four '''''underscore''''' plot.py.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:16&lt;br /&gt;
| Add this line as the first line in the '''script''', '''from numpy import '''''asterisk''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:24 &lt;br /&gt;
| When we use''' asterisk''' in '''imports, '''all the '''functions''' and '''constants''' are imported from '''numpy module'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:32&lt;br /&gt;
| '''linspace''' is a '''function''' available in '''numpy.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:36&lt;br /&gt;
| Press '''Ctrl + S''' to save the file.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:40&lt;br /&gt;
| Now let us run the '''script''' again. Now it gave another '''NameError: name ‘plot’ is not defined.'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:49&lt;br /&gt;
| Let us edit the '''four '''''underscore''''' plot.py '''file''' '''again.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|03:54&lt;br /&gt;
| Add the following as the second line in our '''script'''. '''from matplotlib.pyplot import *'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:04 &lt;br /&gt;
| Now save the file. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:06&lt;br /&gt;
| '''plot''' is a '''function''' which is available in the '''matplotlib.pyplot. '''&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
|04:12 &lt;br /&gt;
|We will run the '''script''' again. We get the output now. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|04:19&lt;br /&gt;
| We '''imported''' all the required '''modules''' using the '''keyword import'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:24&lt;br /&gt;
| Let me close this window.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:28 &lt;br /&gt;
| We can import only '''functions''' which are required from a '''module''' as, '''from numpy import linspace, pi, sin'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|04:37&lt;br /&gt;
| instead of, '''from numpy import *''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:44&lt;br /&gt;
| In the same way we can import only required '''functions''' from '''matplotlib.pyplot'''&lt;br /&gt;
instead of, '''from matplotlib.pyplot import *'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:59&lt;br /&gt;
|  It is always good to use '''function''' names instead of '''asterisk'''. &lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
| 05:03&lt;br /&gt;
|If we use '''asterisk''' to '''import''' from a particular '''module,''' all the '''functions '''will be imported.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:11&lt;br /&gt;
|It replaces some existing '''functions''' with the same name in the '''namespace'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:17&lt;br /&gt;
| Now we will add only required '''functions''' from '''numpy''' and '''matplotlib.pyplot'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:25&lt;br /&gt;
| Let us save the file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:27&lt;br /&gt;
| We will run the code again in the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:32&lt;br /&gt;
| Here, we got the '''plots '''for''' x, -x, sin of x '''and''' xsin of x''' in a single '''figure'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:40&lt;br /&gt;
| In this method we '''imported''' all the required '''functions''' to the current '''namespace'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:46&lt;br /&gt;
| There is another way of fixing errors. Let us see that.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:51&lt;br /&gt;
| Open the file '''another''''' underscore '''''fix.py'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|05:56&lt;br /&gt;
| This file is also available in the '''Code files''' link of this tutorial.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:01&lt;br /&gt;
| Notice that we are going to use the name '''plt''' instead of '''matplotlib.pyplot'''.''' '''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:08&lt;br /&gt;
| '''plt '''is used as alias to the '''module matplotlib.pyplot'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:14&lt;br /&gt;
| Now, we use '''numpy.pi '''instead of just''' pi '''as we did in four'' underscore ''plot.py.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:22&lt;br /&gt;
| '''Plot functions '''are called as &lt;br /&gt;
&lt;br /&gt;
'''plt.plot()'''&lt;br /&gt;
&lt;br /&gt;
'''plt.legend()'''&lt;br /&gt;
&lt;br /&gt;
'''plt.annotate() '''&lt;br /&gt;
&lt;br /&gt;
'''plt.xlim'''&lt;br /&gt;
&lt;br /&gt;
'''plt.ylim'''&lt;br /&gt;
&lt;br /&gt;
and '''plt.show()'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:43&lt;br /&gt;
| The advantage is that '''function''' names in '''imported modules''' do not get added to the current '''namespace'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|06:51&lt;br /&gt;
| In order to use a '''function''' in an '''imported module''', we need to mention '''module-name.function-name'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:59 &lt;br /&gt;
| Pause the video here.Try this exercise and then resume the video. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:05&lt;br /&gt;
| Write a '''python script''' to '''plot''' a '''sine wave''' from''' -2pi '''to''' 2pi'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:12 &lt;br /&gt;
| Open the file '''sine.py''' for the solution. This file is also available in the '''Code files''' link. In the first line we '''import''' the required '''functions.'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:27&lt;br /&gt;
| The '''functions linspace, sin '''and''' constant pi''' are imported from the''' module numpy'''.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:34&lt;br /&gt;
| We '''import''' the '''functions plot, legend, show, title, xlabel '''and''' ylabel '''from''' matplotlib.pyplot.''' &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:44&lt;br /&gt;
| And the rest of the '''code''' is to generate the '''plot'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:48&lt;br /&gt;
| Let us run the '''code''' and see the output.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:52&lt;br /&gt;
| In the '''terminal''', type '''python3''' '''sine.py'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|07:58&lt;br /&gt;
| Now we can see our '''sine plot'''. Close the '''terminal'''.Let us move further in our topic. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:08&lt;br /&gt;
| We can run '''Python scripts''' in '''IPython interpreter '''also.&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|08:13&lt;br /&gt;
| Open another '''terminal''' and start the '''ipython interpreter''' by typing '''ipython3'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:22&lt;br /&gt;
| Navigate to the '''directory''' where '''four '''''underscore''''' plot.py''' is saved and type ''percentage''''' run four '''''underscore''''' plot.py'''&lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|08:35&lt;br /&gt;
| As before we can see the output with 4 '''plots'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:40&lt;br /&gt;
| '''Python''' has a very rich '''standard library''' of '''modules'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|08:45&lt;br /&gt;
|Some of the '''standard modules''' are, &lt;br /&gt;
&lt;br /&gt;
for''' Math: math, random '''&lt;br /&gt;
&lt;br /&gt;
for''' Internet access: urllib2, smtplib'''&lt;br /&gt;
&lt;br /&gt;
for''' System and Command line arguments: sys '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:01&lt;br /&gt;
| Few more '''libraries'''&lt;br /&gt;
&lt;br /&gt;
for''' Operating system interface: os '''&lt;br /&gt;
&lt;br /&gt;
for''' regular expression: re '''&lt;br /&gt;
&lt;br /&gt;
for''' compression: gzip, zipfile, tarfile '''&lt;br /&gt;
&lt;br /&gt;
For more information refer to the below link.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|09:20&lt;br /&gt;
|This brings us to the end of this tutorial. Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|09:26&lt;br /&gt;
|In this tutorial, we have learnt to, &lt;br /&gt;
&lt;br /&gt;
Run '''scripts''' from '''command line''' &lt;br /&gt;
&lt;br /&gt;
'''Import modules''' by specifying the '''module''' name followed by an '''asterisk''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|09:38 &lt;br /&gt;
|'''Import''' only the required '''functions''' from '''modules''' by specifying the '''function''' name&lt;br /&gt;
&lt;br /&gt;
Use '''Python standard library'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|09:47 &lt;br /&gt;
|Here are some self assessment questions for you to solve &lt;br /&gt;
&lt;br /&gt;
1. Which among the below is the most correct?&lt;br /&gt;
&lt;br /&gt;
2. How the functions '''xlim() '''and '''ylim'''() can be imported to the current '''namespace'''? &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|10:02 &lt;br /&gt;
|And the answers, &lt;br /&gt;
&lt;br /&gt;
1. The option '''from matplotlib.pyplot import plot''' is the most correct one.&lt;br /&gt;
&lt;br /&gt;
Because '''plot''' is a '''function''' of '''matplotlib.pyplot''' '''module'''. &lt;br /&gt;
&lt;br /&gt;
|- &lt;br /&gt;
|10:18&lt;br /&gt;
| 2. Functions '''xlim'''() and '''ylim'''() can be '''imported''' to the current '''namespace''' as, '''from matplotlib.pyplot import xlim, ylim''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:32&lt;br /&gt;
| Please post your timed queries in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:36&lt;br /&gt;
| Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:41&lt;br /&gt;
| FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:45&lt;br /&gt;
| Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.For more details, visit this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 10:56&lt;br /&gt;
| This is Priya from IIT Bombay signing off. Thanks for watching.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pratik kamble</name></author>	</entry>

	</feed>