<?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=Being-Creative-with-AI%2FC3%2FPython-Functions-in-Google-Colab%2FEnglish</id>
		<title>Being-Creative-with-AI/C3/Python-Functions-in-Google-Colab/English - 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=Being-Creative-with-AI%2FC3%2FPython-Functions-in-Google-Colab%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Being-Creative-with-AI/C3/Python-Functions-in-Google-Colab/English&amp;action=history"/>
		<updated>2026-05-20T17:20:07Z</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=Being-Creative-with-AI/C3/Python-Functions-in-Google-Colab/English&amp;diff=57771&amp;oldid=prev</id>
		<title>Misbah: Created page with &quot;{|border=1  |-  || '''Visual Cue'''  | '''Narration'''  |-  || Title Slide  | Welcome to this '''Spoken''' '''tutorial''' on '''Python Functions in Google Colab. '''  |-  || '...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Being-Creative-with-AI/C3/Python-Functions-in-Google-Colab/English&amp;diff=57771&amp;oldid=prev"/>
				<updated>2026-05-15T07:31:49Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{|border=1  |-  || &amp;#039;&amp;#039;&amp;#039;Visual Cue&amp;#039;&amp;#039;&amp;#039;  | &amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;  |-  || Title Slide  | Welcome to this &amp;#039;&amp;#039;&amp;#039;Spoken&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;tutorial&amp;#039;&amp;#039;&amp;#039; on &amp;#039;&amp;#039;&amp;#039;Python Functions in Google Colab. &amp;#039;&amp;#039;&amp;#039;  |-  || &amp;#039;...&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;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Visual Cue'''&lt;br /&gt;
&lt;br /&gt;
| '''Narration'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Title Slide&lt;br /&gt;
&lt;br /&gt;
| Welcome to this '''Spoken''' '''tutorial''' on '''Python Functions in Google Colab. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Learning Objectives Slide'''&lt;br /&gt;
&lt;br /&gt;
| In this tutorial, you will learn to:&lt;br /&gt;
&lt;br /&gt;
• Define a new '''function''' using '''def'''.&lt;br /&gt;
&lt;br /&gt;
• Call the '''function''' by its name.&lt;br /&gt;
&lt;br /&gt;
• Use '''parameters''' and''' return values.'''&lt;br /&gt;
&lt;br /&gt;
• Handle minor '''coding''' errors.&lt;br /&gt;
&lt;br /&gt;
• Improve '''function''' using a '''default parameter'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Disclaimer slide '''&lt;br /&gt;
&lt;br /&gt;
| As Al tools constantly evolve, if you are unable to locate any icon or encounter difficulty at any step, you may use any conversational Al Chatbot for guidance. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''System Requirements Slide'''&lt;br /&gt;
&lt;br /&gt;
| I am using the following setup:&lt;br /&gt;
&lt;br /&gt;
• A computer with Internet connection.&lt;br /&gt;
&lt;br /&gt;
• A Web browser such as '''Chrome''', '''Firefox''', or '''Edge'''.&lt;br /&gt;
&lt;br /&gt;
• An active '''Google account to '''access '''Google Colab.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Prerequisite Slide'''&lt;br /&gt;
&lt;br /&gt;
For the Pre-requisites of this tutorial, visit the '''website '''shown on your screen'''&lt;br /&gt;
&lt;br /&gt;
'''https://EduPyramids.org'''&lt;br /&gt;
&lt;br /&gt;
| Learners should be familiar with Basic knowledge of '''Python syntax.'''&lt;br /&gt;
&lt;br /&gt;
For the Pre-requisites of this tutorial, visit the '''website '''shown on your screen.''' '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Show the code file'''&lt;br /&gt;
&lt;br /&gt;
The following code file is required to practice this tutorial.&lt;br /&gt;
&lt;br /&gt;
1. Creating-a-Greeting.txt&lt;br /&gt;
&lt;br /&gt;
This file is provided in the code files link of this tutorial page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please download and extract the file.&lt;br /&gt;
&lt;br /&gt;
| The following '''code file''' is required to practice this '''tutorial'''.&lt;br /&gt;
&lt;br /&gt;
This file is provided in the '''Code Files link''' of this '''tutorial '''page.&lt;br /&gt;
&lt;br /&gt;
Please download and extract the file. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show slide: What is a function?&lt;br /&gt;
&lt;br /&gt;
| Let’s now understand what a '''function''' is.&lt;br /&gt;
&lt;br /&gt;
A '''function''' is reusable '''code''' for a specific action. &lt;br /&gt;
&lt;br /&gt;
We define it once and use it many times.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show Google Colab homepage&lt;br /&gt;
&lt;br /&gt;
| We will use '''Google Colab, a cloud-based editor''' in this tutorial.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show browser address bar with colab.research.google.com&lt;br /&gt;
&lt;br /&gt;
| Open any '''web browser''' and Log into your '''Google account. '''&lt;br /&gt;
&lt;br /&gt;
Now in the '''address bar''',  '''type''' '''colab dot research dot google dot com''' press '''enter'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show Google Colab welcome page&lt;br /&gt;
&lt;br /&gt;
| '''Welcome to colab webpage '''opens with an '''Open notebook window'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Highlight “New Notebook” button&lt;br /&gt;
&lt;br /&gt;
| To begin, we will create a '''new notebook'''.&lt;br /&gt;
&lt;br /&gt;
So go to the bottom left of this '''window '''and''' click '''on the '''tab plus New notebook.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show new Colab notebook opening&lt;br /&gt;
&lt;br /&gt;
| A new '''webpage''' opens. &lt;br /&gt;
&lt;br /&gt;
The''' file''' name appears on the top left corner of the '''webpage'''. &lt;br /&gt;
&lt;br /&gt;
By default it  is named as this'''.'''&lt;br /&gt;
&lt;br /&gt;
Let us rename this as shown on the screen.&lt;br /&gt;
&lt;br /&gt;
This '''file''' is automatically saved to your '''Google drive. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Blank code cell shown&lt;br /&gt;
&lt;br /&gt;
| Now, we are ready to write a''' Python function'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code cell (empty)&lt;br /&gt;
&lt;br /&gt;
| Let us write our first''' function''' now. &lt;br /&gt;
&lt;br /&gt;
We will create a simple '''function''' to generate a personalized greeting.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| def create_greeting(name):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return f&amp;quot;Welcome, {name}!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
| In the coding bar, type: '''def create underscore greeting open parenthesis name close parenthesis colon'''&lt;br /&gt;
&lt;br /&gt;
Press '''Enter'''. &lt;br /&gt;
&lt;br /&gt;
Press '''Tab''' key for indentation and '''type''' the '''return''' statement as shown here.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Mouse hover on the play button &lt;br /&gt;
&lt;br /&gt;
| Press '''control''' and '''Enter''' to''' run''' the''' cell.'''&lt;br /&gt;
&lt;br /&gt;
You can also''' click''' on the '''play button '''on the left of the coding bar to '''run''' the cell.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| New cell below&lt;br /&gt;
&lt;br /&gt;
| The '''function''' is ready to use.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Highlight the bold words as narrated &lt;br /&gt;
def create_greeting(name):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| The keyword '''def''' tells '''Python''' to create a '''function'''.&lt;br /&gt;
&lt;br /&gt;
'''create under score greeting''' is the '''function''' name.&lt;br /&gt;
&lt;br /&gt;
Every time you start a new '''function''', you’ll use '''def '''followed by the '''function’s''' name.&lt;br /&gt;
&lt;br /&gt;
'''Name''' is the '''input''', also called a '''parameter'''.&lt;br /&gt;
&lt;br /&gt;
'''Return''' sends a value back to the '''caller'''.&lt;br /&gt;
&lt;br /&gt;
The''' f-string '''inserts the name into the sentence.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show on screen '''+ Code'''&lt;br /&gt;
&lt;br /&gt;
print(create_greeting('Alex'))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| Now, press '''plus Code'''&lt;br /&gt;
&lt;br /&gt;
A new cell will open. &lt;br /&gt;
&lt;br /&gt;
You can call the '''function''' by typing the '''command''' shown on the '''screen'''.&lt;br /&gt;
&lt;br /&gt;
Press '''Shift''' and '''Enter'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show output&lt;br /&gt;
&lt;br /&gt;
| Here is the '''output''':''' Welcome, Alex!'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting('Asha'))&lt;br /&gt;
&lt;br /&gt;
print(create_greeting('Rahul'))&lt;br /&gt;
&lt;br /&gt;
| Pause the '''tutorial''' here. Try other names like ''''Asha'''' or ''''Rahul''''. &lt;br /&gt;
&lt;br /&gt;
Observe the '''output''' and resume the '''tutorial'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show the outputs &lt;br /&gt;
&lt;br /&gt;
| The '''function''' works for any name we provide.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show slide: Store the result&lt;br /&gt;
&lt;br /&gt;
| Now, let us see how we can store the result in a '''variable'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code block&lt;br /&gt;
&lt;br /&gt;
greet = create_greeting('Sam')&lt;br /&gt;
&lt;br /&gt;
| Open a new cell by clicking on '''plus Code. '''&lt;br /&gt;
&lt;br /&gt;
If you already have a new cell, you may ignore this step.&lt;br /&gt;
&lt;br /&gt;
Now pause the video and type the command as shown on the screen.&lt;br /&gt;
&lt;br /&gt;
Press '''Shift''' and '''Enter'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code block&lt;br /&gt;
print(greet)&lt;br /&gt;
&lt;br /&gt;
| Next in a new cell type this. &lt;br /&gt;
&lt;br /&gt;
press '''Shift''' and '''Enter'''. &lt;br /&gt;
&lt;br /&gt;
The output is: '''Welcome Sam!'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show slide: Common mistake&lt;br /&gt;
&lt;br /&gt;
| Let us look at a common mistake we might make while using functions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting(Alex))&lt;br /&gt;
&lt;br /&gt;
| Let me '''type''' the following '''code '''and press the play button to run it.&lt;br /&gt;
&lt;br /&gt;
Do you notice the error? &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting(Alex))&lt;br /&gt;
&lt;br /&gt;
print(create_greeting('Alex'))&lt;br /&gt;
&lt;br /&gt;
| Can you tell what could be the possible reason?&lt;br /&gt;
&lt;br /&gt;
Let me add our previous command next to it.&lt;br /&gt;
&lt;br /&gt;
Now can you tell what was the mistake. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show fix&lt;br /&gt;
&lt;br /&gt;
print(create_greeting('Alex')).&lt;br /&gt;
&lt;br /&gt;
| Yes, always remember to use quotes around the value you want to print.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting(‘Alex’))&lt;br /&gt;
&lt;br /&gt;
| Another common mistake is when we forget to '''run''' the '''cell''' with '''def''' first. &lt;br /&gt;
&lt;br /&gt;
If we do not '''run''' the '''cell''', '''python''' will not know that the '''function''' exists. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting(‘Alex’))&lt;br /&gt;
&lt;br /&gt;
| Now, when we run '''print open parenthesis create underscore greeting open parenthesis single quote Alex close quote close parenthesis and again close parenthesis'''&lt;br /&gt;
&lt;br /&gt;
a '''NameError''' occurs.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show slide: Optional improvement&lt;br /&gt;
&lt;br /&gt;
| To make our '''function''' better, let us add a default value to the parameter.&lt;br /&gt;
&lt;br /&gt;
This allows the '''function''' to work without a name.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code block&lt;br /&gt;
&lt;br /&gt;
def create_greeting(name='Friend'):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| Let us understand this with the '''code''' that we used earlier in this tutorial&lt;br /&gt;
&lt;br /&gt;
We start with '''def''', followed by the function name.&lt;br /&gt;
&lt;br /&gt;
Inside the parenthesis, we see; '''name equals 'Friend''''.&lt;br /&gt;
&lt;br /&gt;
'''Name''' is our parameter or input variable.&lt;br /&gt;
&lt;br /&gt;
''''Friend'''' is the '''default value'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code block&lt;br /&gt;
&lt;br /&gt;
def create_greeting(name='Friend'):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| The next line starts with the '''return''' keyword.&lt;br /&gt;
&lt;br /&gt;
This sends the formatted '''string''' back to the user.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| Show code block&lt;br /&gt;
&lt;br /&gt;
def create_greeting(name='Friend'):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| Why do we use a default value?&lt;br /&gt;
It acts as a safety net for our code.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting(‘Alex’))&lt;br /&gt;
&lt;br /&gt;
| If we provide a name like ''''Alex'''', '''Python''' ignores the default and uses ''''Alex''''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| print(create_greeting())&lt;br /&gt;
&lt;br /&gt;
Output: Welcome, Friend!&lt;br /&gt;
&lt;br /&gt;
| Now, let us call the '''function''' with empty brackets.&lt;br /&gt;
&lt;br /&gt;
Type the '''command''' as shown and '''run''' the cell.&lt;br /&gt;
&lt;br /&gt;
'''Python''' now uses the default value ''''Friend''''.&lt;br /&gt;
&lt;br /&gt;
Default values prevent errors when input is missing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Summary slides'''&lt;br /&gt;
&lt;br /&gt;
Summary of what we have learnt:&lt;br /&gt;
&lt;br /&gt;
• Define a new function using def&lt;br /&gt;
&lt;br /&gt;
• Call the function by its name&lt;br /&gt;
&lt;br /&gt;
• Use parameters and return values&lt;br /&gt;
&lt;br /&gt;
• Handle small coding errors&lt;br /&gt;
&lt;br /&gt;
• Improve your function using a default parameter&lt;br /&gt;
&lt;br /&gt;
| This brings us to the end of this '''tutorial'''. &lt;br /&gt;
&lt;br /&gt;
Here is a summary of what we learnt. &lt;br /&gt;
&lt;br /&gt;
• Define a new function using def&lt;br /&gt;
&lt;br /&gt;
• Call the function by its name&lt;br /&gt;
&lt;br /&gt;
• Use parameters and return values&lt;br /&gt;
&lt;br /&gt;
• Handle small coding errors&lt;br /&gt;
&lt;br /&gt;
• Improve your function using a default parameter&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Assignment slide'''&lt;br /&gt;
1) Create a function make_tagline(product) &lt;br /&gt;
&lt;br /&gt;
2) It should return  'The best choice: {product_name}'. &lt;br /&gt;
&lt;br /&gt;
3) Call it with three products of your choice.&lt;br /&gt;
&lt;br /&gt;
4) Print each tagline on a new line.&lt;br /&gt;
&lt;br /&gt;
| Here is an assignment&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|| Acknowledgement &lt;br /&gt;
&lt;br /&gt;
| Thank you&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|| '''Closing slide'''&lt;br /&gt;
This ''' Spoken tutorial '''is brought to you by '''EduPyramids Educational Services Private Limited, SINE, IIT Bombay.'''&lt;br /&gt;
&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Misbah</name></author>	</entry>

	</feed>