<?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%2FC3%2FGetting-started-with-tuples%2FEnglish-timed</id>
		<title>Python-3.4.3/C3/Getting-started-with-tuples/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%2FC3%2FGetting-started-with-tuples%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Getting-started-with-tuples/English-timed&amp;action=history"/>
		<updated>2026-04-10T05:50:26Z</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/C3/Getting-started-with-tuples/English-timed&amp;diff=47673&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot;{| border=1 |  &lt;center&gt;'''Time'''&lt;/center&gt; |  &lt;center&gt;'''Narration'''&lt;/center&gt;  |- |  00:01 |  Welcome to the spoken tutorial on '''Getting Started with tuples'''.   |- | 00:0...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Getting-started-with-tuples/English-timed&amp;diff=47673&amp;oldid=prev"/>
				<updated>2019-06-04T07:13:45Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| border=1 |  &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt; |  &amp;lt;center&amp;gt;&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;&amp;lt;/center&amp;gt;  |- |  00:01 |  Welcome to the spoken tutorial on &amp;#039;&amp;#039;&amp;#039;Getting Started with tuples&amp;#039;&amp;#039;&amp;#039;.   |- | 00:0...&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;
|  &amp;lt;center&amp;gt;'''Time'''&amp;lt;/center&amp;gt;&lt;br /&gt;
|  &amp;lt;center&amp;gt;'''Narration'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:01&lt;br /&gt;
|  Welcome to the spoken tutorial on '''Getting Started with tuples'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:07&lt;br /&gt;
|  In this tutorial we will:  Understand what '''tuples''' are&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:12&lt;br /&gt;
|  Compare '''tuples''' with '''lists'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:15&lt;br /&gt;
|  Know why they are needed and Learn to use them. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:21&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;
|-&lt;br /&gt;
|  00:29&lt;br /&gt;
| '''Python 3.4.3 '''and  '''IPython 5.1.0'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:36&lt;br /&gt;
|  To practise this tutorial, you should know how to&lt;br /&gt;
&lt;br /&gt;
run basic '''Python '''commands on the '''ipython console'''&lt;br /&gt;
&lt;br /&gt;
and  use '''lists'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:47&lt;br /&gt;
|  If not, see the relevant '''Python '''tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:53&lt;br /&gt;
|  First we will learn about '''tuples'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  00:57&lt;br /&gt;
| '''Tuple''' is a collection of '''elements''' similar to a '''list'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:02&lt;br /&gt;
|   '''Tuple''' uses '''parentheses''', whereas list uses '''square brackets.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:08&lt;br /&gt;
| '''Elements''' of a '''tuple''' cannot be changed once it is assigned.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:13&lt;br /&gt;
|  But in a '''list, elements''' can be changed.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:17&lt;br /&gt;
|  Here are few examples for declaring '''tuples'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:21&lt;br /&gt;
|  ''Inside brackets'' 1, 2.5 is a '''tuple''' with two '''elements'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:27&lt;br /&gt;
|  The same can be declared as 1, 2.5. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:32&lt;br /&gt;
|  ''Inside brackets ''1 comma is a '''tuple''' with one '''element'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:37&lt;br /&gt;
|  The same can be declared as 1 comma &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:41&lt;br /&gt;
|  &lt;br /&gt;
''Inside brackets again inside brackets ''1 comma and outside bracket a comma is a '''tuple''' with one '''tuple''' as '''element'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  01:52&lt;br /&gt;
|  The same can be declared as ''inside brackets'' 1 comma and outside bracket a comma.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:59&lt;br /&gt;
| Let us start '''ipython'''. Open the '''terminal.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:04&lt;br /&gt;
| Type '''ipython3 '''and press '''Enter.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:10&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:17&lt;br /&gt;
|  Let's learn to create a '''tuple'''. &lt;br /&gt;
&lt;br /&gt;
Type, '''t '''''is equal to inside brackets''''' 1 '''''comma''''' 2.5 '''''comma''''' '''''inside double quotes '''''hello '''''comma''''' minus 4 '''''comma''''' '''''inside double quotes '''''world '''''comma''''' 1.24 '''''comma''''' 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:38&lt;br /&gt;
|  Type, '''t'''&lt;br /&gt;
&lt;br /&gt;
It is similar to '''list''' except that '''parentheses''' are used instead of '''square brackets'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:47&lt;br /&gt;
|  At least one comma is mandatory for a '''tuple'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:51&lt;br /&gt;
|  The brackets are optional, but should be added for clarity.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  02:56&lt;br /&gt;
|  The items in the '''tuple''' can be accessed by their '''index''' '''positions'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:02&lt;br /&gt;
|  Type, '''t '''''inside square brackets '''''3'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:07&lt;br /&gt;
|  Type, '''t '''''inside square brackets '''''1 '''''colon '''''5 '''''colon '''''2'''&lt;br /&gt;
&lt;br /&gt;
It prints the corresponding '''slice.''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:16&lt;br /&gt;
|  Now we try to change an '''element''' in the '''tuple'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:20&lt;br /&gt;
|  Type, '''t '''''inside square brackets '''''2 '''''is equal to''''' '''''inside double quotes '''''Hello'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:28&lt;br /&gt;
|  We can see that, it raises an error saying ''''tuple object does not support item assignment''''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:35&lt;br /&gt;
|  It shows, '''elements''' of a '''tuple''' cannot be changed after it is created. &lt;br /&gt;
&lt;br /&gt;
This is called '''immutability. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:44&lt;br /&gt;
|  We can iterate over '''tuples''' like '''lists'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:48&lt;br /&gt;
|  Type, '''for x in t '''''colon''&lt;br /&gt;
&lt;br /&gt;
'''print '''''inside brackets '''''x'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  03:57&lt;br /&gt;
|  It prints each '''element''' of the '''tuple t.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:01&lt;br /&gt;
|  Pause the video. &lt;br /&gt;
&lt;br /&gt;
Try this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:07&lt;br /&gt;
|  Let us look at a simple problem of '''swapping values'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:12&lt;br /&gt;
|  Given, '''a''''' is equal to''''' 5''' and '''b '''''is equal to''''' 7''', swap the values of '''a''' and '''b'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:20&lt;br /&gt;
|  Switch to the '''terminal''' for the solution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:24&lt;br /&gt;
|  Type, '''a '''''is equal to''''' 5'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:28&lt;br /&gt;
|  '''b '''''is equal to''''' 7'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:32&lt;br /&gt;
|  Then type, '''a'''&lt;br /&gt;
&lt;br /&gt;
Type, '''b'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:38&lt;br /&gt;
|  We now create a '''variable''' say, '''temp '''and '''swap''' the '''values''' using this '''variable.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:45&lt;br /&gt;
|  Type &lt;br /&gt;
&lt;br /&gt;
'''temp '''''is equal to''''' a '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:49&lt;br /&gt;
|  '''a '''''is equal to''''' b'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:53&lt;br /&gt;
|  '''b '''''is equal to''''' temp'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  04:57&lt;br /&gt;
| Then type, '''a'''&lt;br /&gt;
&lt;br /&gt;
Type, '''b'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:02&lt;br /&gt;
|  We can see that the values are successfully swapped now.&lt;br /&gt;
&lt;br /&gt;
But this is the traditional approach.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:10&lt;br /&gt;
|  Now let us do it in the '''Python''' way. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:14&lt;br /&gt;
|  Type&lt;br /&gt;
&lt;br /&gt;
'''a '''''is equal to''''' 5'''&lt;br /&gt;
&lt;br /&gt;
'''b '''''is equal to''''' 7'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:21&lt;br /&gt;
|  '''a, b '''''is equal to''''' b, a'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:27&lt;br /&gt;
|  Now we will check whether the values are swapped.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:31&lt;br /&gt;
|  Type, '''a'''&lt;br /&gt;
&lt;br /&gt;
Type, '''b'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:36&lt;br /&gt;
|  We can see that the '''values''' are '''swapped''' easily.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:40&lt;br /&gt;
|  We can also do this for different '''datatypes'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:44&lt;br /&gt;
|  Type, '''a '''''is equal to''''' 2.5 '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:49&lt;br /&gt;
| '''b '''''is equal to inside double quotes''''' hello'''&lt;br /&gt;
&lt;br /&gt;
'''a, b '''''is equal to''''' b, a'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  05:59&lt;br /&gt;
|  Now to check the values, type, '''a'''&lt;br /&gt;
&lt;br /&gt;
Type, '''b'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:07&lt;br /&gt;
|  This is possible because of the '''immutability''' of '''tuples'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:12&lt;br /&gt;
|  This is called''' tuple packing''' and '''unpacking'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:16&lt;br /&gt;
|  When you type, '''a''' ''comma'' '''b''' ''is equal to'' '''b''' ''comma'' '''a''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:21&lt;br /&gt;
|  First, the values of '''b''' and '''a''' are '''packed''' into a '''tuple''' on the right side. Then it is '''unpacked''' into the '''variables''' '''a''' and '''b'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:32&lt;br /&gt;
|  Let us first see about '''tuple packing'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:36&lt;br /&gt;
|  Type, '''5 '''''comma''&lt;br /&gt;
&lt;br /&gt;
We can see a '''tuple''' with one '''element'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:43&lt;br /&gt;
|  Type, '''5 '''''comma inside double quotes '''''hello '''''comma''''' 2.5 '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:49&lt;br /&gt;
|  Now it is a '''tuple''' with three '''elements'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  06:53&lt;br /&gt;
|  When we type two or more '''elements''' separated by '''commas''', those '''elements''' are packed into a '''tuple'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:01&lt;br /&gt;
|  '''Immutability''' of '''tuples''' ensures that the '''values''' are not changed during the '''packing''' and '''unpacking'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:09&lt;br /&gt;
|  This brings us to the end of this tutorial. Let us summarize.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:15&lt;br /&gt;
|  In this tutorial, we have learnt about, '''Tuples''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:21&lt;br /&gt;
|  Similarities of '''tuples''' with '''lists'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:25&lt;br /&gt;
|  '''Immutability''' of '''tuples''' and Concept of '''Packing''' and '''unpacking''' of '''tuples'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:32&lt;br /&gt;
| Here are some self assessment questions for you to solve. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:36&lt;br /&gt;
| First. Define a '''tuple''' containing two values as given below. The first value is '''integer''' 4 and the second value is '''float''' 2.5. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:50&lt;br /&gt;
|  Second. If we type, '''a''' ''is equal to''''' 5''' ''comma ''then what is the '''datatype''' of '''a'''? &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  07:58&lt;br /&gt;
| Third. If we type, '''a''' ''is equal to inside brackets '''''2''' ''comma '''''3   a''' ''inside square brackets '''''0''' ''comma'' '''a''' ''inside square brackets '''''1''' ''is equal to inside brackets '''''3''' ''comma'' '''4''' &lt;br /&gt;
&lt;br /&gt;
What is the output?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:16&lt;br /&gt;
|  And the answers,&lt;br /&gt;
&lt;br /&gt;
First. A '''tuple''' is defined by enclosing '''parentheses''' around a sequence of items separated by commas. Hence, we write our '''tuple''' as, ''inside brackets ''4 ''comma'' 2.5&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:32&lt;br /&gt;
|  Second. Since the given data is 5 followed by a comma, it is a '''tuple''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:39&lt;br /&gt;
| Third. The given operation will give a '''TypeError''' because '''tuples''' are '''immutable'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:46&lt;br /&gt;
|  Please post your timed queries in this forum. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  08:50&lt;br /&gt;
|  Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:55&lt;br /&gt;
|  FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|08:59&lt;br /&gt;
|Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.&lt;br /&gt;
&lt;br /&gt;
For more details, visit this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|  09:09&lt;br /&gt;
|  This is Priya from IIT Bombay signing off.&lt;br /&gt;
&lt;br /&gt;
Thanks for watching.&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>