<?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%2FGetting-Started-with-Functions%2FEnglish-timed</id>
		<title>Python-3.4.3/C4/Getting-Started-with-Functions/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%2FGetting-Started-with-Functions%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Getting-Started-with-Functions/English-timed&amp;action=history"/>
		<updated>2026-04-28T23:29:18Z</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/Getting-Started-with-Functions/English-timed&amp;diff=47712&amp;oldid=prev</id>
		<title>Pratik kamble: Created page with &quot;{|Border=1 |'''Time''' |'''Narration'''  |- |00:01  |Welcome to the spoken tutorial on '''Getting started with''' '''functions'''.   |- |00:06 |In this tutorial, we will learn...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Getting-Started-with-Functions/English-timed&amp;diff=47712&amp;oldid=prev"/>
				<updated>2019-06-10T08:50:26Z</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;Getting started with&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;functions&amp;#039;&amp;#039;&amp;#039;.   |- |00:06 |In this tutorial, we will learn...&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 '''Getting started with''' '''functions'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:06&lt;br /&gt;
|In this tutorial, we will learn to,&lt;br /&gt;
&lt;br /&gt;
Define a '''function'''&lt;br /&gt;
&lt;br /&gt;
Define '''functions''' with '''arguments''' and&lt;br /&gt;
&lt;br /&gt;
use '''docstrings'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:17&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 '''and&lt;br /&gt;
&lt;br /&gt;
'''IPython 5.1.0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:32&lt;br /&gt;
| To practise this tutorial, you should know how to use '''tuples.'''&lt;br /&gt;
&lt;br /&gt;
If not, see the relevant '''Python''' tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:44&lt;br /&gt;
| First we will learn about functions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:48&lt;br /&gt;
|A '''function''' is a portion of '''code''' within a larger '''program''' that performs a specific task. &lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
|00:55&lt;br /&gt;
|'''Functions '''are useful in reusing the '''code''' and eliminate code redundancy.&lt;br /&gt;
 &lt;br /&gt;
|-&lt;br /&gt;
|01:01&lt;br /&gt;
|'''Functions''' are also used to organise our code into manageable blocks. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:07&lt;br /&gt;
| Here is the syntax for defining the '''functions'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:11&lt;br /&gt;
|'''def''' is the '''keyword '''which defines the '''function''' name.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:15&lt;br /&gt;
|colon is used to mark the end of the '''function''' name.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:19&lt;br /&gt;
|'''docstring''' is the documentation string to describe what the '''function''' does.&lt;br /&gt;
&lt;br /&gt;
It is an optional, but recommended.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:29&lt;br /&gt;
|'''Statement''' makes the function body and it must have 4 indentation level.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:36&lt;br /&gt;
|'''return''' statement is to return a value from the function and it is also indented by 4 spaces.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:44&lt;br /&gt;
| Now we will understand the '''functions''' with an example.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:49&lt;br /&gt;
|Consider a mathematical '''function''' '''f''' ''of''''' x''''' is equal to'' '''x''' ''squared''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:55&lt;br /&gt;
|Here '''x''' is a '''variable'''. '''f '''''of '''''x''' changes when '''x''' changes.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:02&lt;br /&gt;
|Let us define our '''function f '''''of '''''x.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:06&lt;br /&gt;
|The first line '''def f '''''of''''' x '''is used to define the '''function''' '''name''' and its '''parameters.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:13&lt;br /&gt;
|The second line uses the '''function parameters''' to return the required value. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:19&lt;br /&gt;
| Let us start '''ipython.'''&lt;br /&gt;
&lt;br /&gt;
Open the '''terminal'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:24&lt;br /&gt;
| Type '''ipython3 '''and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:29&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:36&lt;br /&gt;
| Type,&lt;br /&gt;
&lt;br /&gt;
'''def f '''''inside brackets '''''x '''''colon'' '''return x '''asterisk '''x'''&lt;br /&gt;
&lt;br /&gt;
and press the '''Enter''' key two times.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:47&lt;br /&gt;
| Let us call the '''f '''''of''' ''x '''with different '''arguments.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:51&lt;br /&gt;
|Type, &lt;br /&gt;
&lt;br /&gt;
'''f '''''inside brackets '''''2'''&lt;br /&gt;
&lt;br /&gt;
'''f '''''inside brackets '''''2.5'''&lt;br /&gt;
&lt;br /&gt;
It returned 4 and 6.25 respectively.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:05&lt;br /&gt;
| Now let us see how to write '''functions''' without '''arguments'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:10&lt;br /&gt;
|Type the code as shown.&lt;br /&gt;
&lt;br /&gt;
It defines a new '''function''' named '''greet''' which will print '''&amp;quot;No function arguments&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:21&lt;br /&gt;
| Now we will call the '''function''' as,'''greet '''''open and close parentheses''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:28&lt;br /&gt;
| Note that it is not mandatory for a '''function''' to '''return''' '''values'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:33&lt;br /&gt;
|The '''function greet''' neither takes any '''arguments''' nor '''returns''' any '''value'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:40&lt;br /&gt;
| Next we will learn how to '''comment''' in a '''code'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:44 &lt;br /&gt;
|'''Documenting/commenting code''' is a good practice.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:48 &lt;br /&gt;
|'''Docstrings''' are triple quoted '''comments''' entered just after the '''function''' '''definition'''. &lt;br /&gt;
&lt;br /&gt;
It implies what the '''function''' does.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:57&lt;br /&gt;
| Let us write a '''function '''which '''returns average '''of two numbers.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:02&lt;br /&gt;
|Type the code as shown. and press the '''Enter''' key two times.&lt;br /&gt;
&lt;br /&gt;
'''Comments''' within triple quotes give a clear explanation about the '''code'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:14&lt;br /&gt;
| Type, '''avg '''''question mark''&lt;br /&gt;
&lt;br /&gt;
Here we can see the '''docstring '''of the '''function avg.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:23&lt;br /&gt;
| Now let us pass 3 and 5 as values to the '''arguments a''' and '''b''' to the '''function avg.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:31&lt;br /&gt;
|Type, '''avg '''''inside brackets''''' 3 '''''comma''''' 5''' We get 4.0 as output.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:41&lt;br /&gt;
|Pause the video.Try this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:47&lt;br /&gt;
| Write a '''function circle '''which returns the '''area''' and '''perimeter''' of a '''circle''' with given radius '''r'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:54&lt;br /&gt;
| Switch back to the '''terminal''' for the solution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:58 &lt;br /&gt;
|Type the '''code''' as shown. Press the '''Enter''' key two times.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:05&lt;br /&gt;
|The '''circle function''' requires us to '''return''' two values. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:10 &lt;br /&gt;
|A '''python function''' can return any number of values in the form of a '''tuple'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:16 &lt;br /&gt;
|Let us call the '''function circle''' as, '''a '''''comma''''' p '''''is equal to''''' circle '''''inside brackets '''''6'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:25&lt;br /&gt;
|Now Type, '''print '''''inside brackets '''''a '''''comma''''' p'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:31&lt;br /&gt;
|We can see the output as area and perimeter of a circle of radius 6.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:38&lt;br /&gt;
|This brings us to the end of this tutorial. Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:44&lt;br /&gt;
|In this tutorial, we have learnt to,&lt;br /&gt;
&lt;br /&gt;
Define '''functions''' in '''Python'''&lt;br /&gt;
&lt;br /&gt;
Call a '''function''' by specifying the '''function''' name&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:54&lt;br /&gt;
|Write '''docstrings''' to a '''function''' by putting it as a triple quoted '''string'''&lt;br /&gt;
&lt;br /&gt;
Pass '''parameters''' to a '''function'''&lt;br /&gt;
&lt;br /&gt;
Return '''values''' from a '''function'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:06&lt;br /&gt;
| Here are some self assessment questions for you to solve&lt;br /&gt;
&lt;br /&gt;
1. How many '''arguments''' can be passed to a '''Python function'''?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:15 &lt;br /&gt;
|2.Write a '''function''' to find the area of a rectangle.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:20&lt;br /&gt;
| And the answers,&lt;br /&gt;
&lt;br /&gt;
1. Any number of '''arguments''' can be passed to a '''Python function'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:28&lt;br /&gt;
|2. We can write a '''function''' to find the area of a rectangle as:'''def rectangle''''' underscore '''''area '''''inside brackets '''''l '''''comma''''' b '''''colon''&lt;br /&gt;
'''return l '''''asterisk''''' b '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:42 &lt;br /&gt;
| Please post your timed queries in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:46 &lt;br /&gt;
| Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:51&lt;br /&gt;
| FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:55&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;
|07:04&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>