<?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%2FDictionaries%2FEnglish-timed</id>
		<title>Python-3.4.3/C3/Dictionaries/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%2FDictionaries%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Dictionaries/English-timed&amp;action=history"/>
		<updated>2026-04-10T04:02:58Z</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/Dictionaries/English-timed&amp;diff=47743&amp;oldid=prev</id>
		<title>Pratik kamble: Created page with &quot;{| border=1 | '''Time''' | '''Narration'''  |- | 00:01 | Welcome to the spoken tutorial on '''Dictionaries'''.   |- | 00:05 |In this tutorial, we will learn to,  Create '''dic...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C3/Dictionaries/English-timed&amp;diff=47743&amp;oldid=prev"/>
				<updated>2019-06-11T08:37:22Z</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;Dictionaries&amp;#039;&amp;#039;&amp;#039;.   |- | 00:05 |In this tutorial, we will learn to,  Create &amp;#039;&amp;#039;&amp;#039;dic...&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 '''Dictionaries'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:05&lt;br /&gt;
|In this tutorial, we will learn to,&lt;br /&gt;
&lt;br /&gt;
Create '''dictionaries'''&lt;br /&gt;
&lt;br /&gt;
Add and delete '''data''' from '''dictionaries'''&lt;br /&gt;
&lt;br /&gt;
Retrieve '''data''' from '''dictionaries'''&lt;br /&gt;
&lt;br /&gt;
Check for presence of '''keys''' and&lt;br /&gt;
&lt;br /&gt;
'''Iterate''' over elements.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 00:25&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:40&lt;br /&gt;
|To practise this tutorial, you should know how to &lt;br /&gt;
&lt;br /&gt;
use''' basic data types '''and''' operators'''&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:54&lt;br /&gt;
| First we will learn about '''dictionaries'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:58&lt;br /&gt;
|'''Dictionary''' is an unordered collection of items which has '''key:value''' pairs.&lt;br /&gt;
&lt;br /&gt;
'''Dictionary''' is used to look up for a specific '''key''' and retrieve the corresponding '''value'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:12&lt;br /&gt;
| '''Keys''' are unique within a dictionary while '''values''' may not be.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:18&lt;br /&gt;
|The values of a dictionary can be of any data type.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:23&lt;br /&gt;
|But the keys must be of immutable data type such as '''strings''', '''numbers''' or '''tuples'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:31&lt;br /&gt;
| Let us start '''ipython'''. Open the '''terminal.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 01:37&lt;br /&gt;
| Type '''ipython3 '''and press '''Enter.''' 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;
| 01:50&lt;br /&gt;
| Let us start by creating an empty '''dictionary'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:54&lt;br /&gt;
|Type, '''empty '''''is equal to''''' '''''open and close curly braces'' Note that unlike '''lists''', '''curly''' '''braces''' are used to define a '''dictionary'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:06&lt;br /&gt;
| Now let us see how to create a non empty '''dictionary'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:11&lt;br /&gt;
|Type as shown. Note that, &lt;br /&gt;
&lt;br /&gt;
Each '''key:value pair''' is separated by a '''comma''',&lt;br /&gt;
&lt;br /&gt;
Each '''key''' is separated from its value by a colon, and &lt;br /&gt;
&lt;br /&gt;
The whole thing is enclosed in curly braces.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:29&lt;br /&gt;
| Here, we have defined four entries in the '''dictionary''' '''student'''.  The '''keys''' are '''name, age, gender, class.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:44&lt;br /&gt;
| Type, '''student''' to see its content.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:50&lt;br /&gt;
| Next let us learn to access the dictionary elements.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 02:55&lt;br /&gt;
| The value of a '''dictionary''' can be accessed using the corresponding''' key'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:01&lt;br /&gt;
|The '''syntax '''is: '''dictionary '''''underscore '''''name '''''inside square brackets '''''key'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:07&lt;br /&gt;
| Now let us access the value for the key''' ‘name’.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:12&lt;br /&gt;
|Type, '''print''' ''inside brackets '''''student '''''inside square brackets inside single quotes '''''name'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:21&lt;br /&gt;
|As expected it''' '''printed the output as''' raj.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:26&lt;br /&gt;
| Now we will retrieve the value for the key''' ‘class’''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:31&lt;br /&gt;
|Type, '''print''' ''inside brackets '''''student '''''inside square brackets inside single quotes '''''class'''&lt;br /&gt;
It displays the output as 10.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:43&lt;br /&gt;
| If we try to access a '''value''' with a wrong '''key''', we get an error.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:49&lt;br /&gt;
|Type, '''student '''''inside square brackets inside single quotes '''''height'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 03:56&lt;br /&gt;
|The '''interpreter''' gave us the '''KeyError:''' ''''height'''' This is because, '''key 'height' '''is not present in the '''student dictionary.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:05&lt;br /&gt;
|This is about creating '''dictionaries.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:09&lt;br /&gt;
| Next, let us see how to '''add''' or '''delete''' '''items '''in a '''dictionary'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:15&lt;br /&gt;
|First let us '''add''' an element''' height '''to the '''dictionary''' '''student.'''&lt;br /&gt;
&lt;br /&gt;
Type, '''student '''''inside square brackets inside single quotes '''''height '''''is equal to''''' 6.2'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:29&lt;br /&gt;
| Let us now check the content of the '''dictionary.''' &lt;br /&gt;
&lt;br /&gt;
Type, '''student''' You can see that '''key-value''' ''''height': 6.2 '''is added to the '''dictionary student.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:42&lt;br /&gt;
| Next let us modify the '''element class '''of the '''dictionary''' '''student.'''&lt;br /&gt;
&lt;br /&gt;
Type, '''student '''''inside square brackets inside single quotes '''''class '''''is equal to '''''11'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 04:56&lt;br /&gt;
| Now, to check the content of the dictionary, type, '''student'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:02&lt;br /&gt;
|As you can see, the value for '''class''' '''key''' is changed to '''11 .'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:06&lt;br /&gt;
| Next let us learn to delete '''age '''from the '''dictionary''' '''student.'''&lt;br /&gt;
&lt;br /&gt;
Type, '''del student '''''inside square brackets inside single quotes '''''age'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:20&lt;br /&gt;
| Type, '''student''' You can see that now '''key-value''' ''''age': 16''' is deleted from '''student. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:29&lt;br /&gt;
| Next let us see how to check whether a '''key''' is present in a '''dictionary'''. &lt;br /&gt;
&lt;br /&gt;
For that we can use the '''method in.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:39&lt;br /&gt;
| The method''' in''' will return '''True''' if the key is found in the '''dictionary.''' It will return '''False''' if '''key''' is not present.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:48&lt;br /&gt;
|Note that we can check only for the presence of the '''keys''' in '''dictionaries''' and not values.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 05:55&lt;br /&gt;
|'''Keys '''of a '''dictionary '''are not ordered.  Hence, '''slicing''' and '''striding''' are not valid on '''dictionaries'''. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:03&lt;br /&gt;
| Let us try it with an example.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:06&lt;br /&gt;
|Type, ''inside single quotes '''''school in student''' We get '''False, '''since the '''key 'school' '''is not present in '''student.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:17&lt;br /&gt;
| Type, ''inside single quotes '''''name in student''' We get '''True''', as expected.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:25&lt;br /&gt;
|Next let us see how to retrieve keys and values of a dictionary.&lt;br /&gt;
&lt;br /&gt;
Method '''keys'''() is used for getting a '''list''' of '''keys'''&lt;br /&gt;
&lt;br /&gt;
Method''' values() '''is''' '''used''' '''for getting a '''list''' of '''values'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:40&lt;br /&gt;
| Now let us try the above methods with examples. Type, '''student''''' dot '''''keys '''''open and close brackets '' It returns the '''list''' of '''keys''' of the '''dictionary''' '''student.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 06:56&lt;br /&gt;
| Type, '''student '''''dot '''''values '''''open and close brackets ''&lt;br /&gt;
It returns the '''list''' of '''values''' of the '''dictionary''' '''student.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:07&lt;br /&gt;
| Next let us see the '''items method.'''&lt;br /&gt;
&lt;br /&gt;
Type, '''student '''''dot '''''items '''''open and close brackets''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:16&lt;br /&gt;
|It returns a '''list''' of '''tuples''' of '''key-value pairs''' of the '''dictionary student.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:22&lt;br /&gt;
|The order of items of the list returned by''' keys(), values() '''and''' items()''' cannot be predicted.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:30&lt;br /&gt;
|In '''dictionaries, '''they are not in the order in which we inserted them.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:35&lt;br /&gt;
| Pause the video. Try this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:41&lt;br /&gt;
| Print the '''keys''' and '''values''' of the '''dictionary student''' one by one. Hint: use the '''method''' '''items''' and '''for loop.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:50&lt;br /&gt;
| Switch back to the terminal for the solution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 07:54&lt;br /&gt;
| Type as shown. It displays the keys and values one by one.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:02&lt;br /&gt;
| This brings us to the end of this tutorial. Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:08&lt;br /&gt;
|In this tutorial, we have learnt to,&lt;br /&gt;
&lt;br /&gt;
Create '''dictionaries''' &lt;br /&gt;
&lt;br /&gt;
Access '''elements''' of a '''dictionary''' using '''keys'''&lt;br /&gt;
&lt;br /&gt;
Add '''elements''' to a '''dictionary''' by assigning a '''value''' to a '''key'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:22&lt;br /&gt;
|Delete '''elements''' from a '''dictionary''' by using the '''function''' '''del'''&lt;br /&gt;
&lt;br /&gt;
Retrieve the '''keys''' and '''values''' by using the '''methods''' '''keys'''() and '''values() '''respectively  &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:34&lt;br /&gt;
| and  Iterate over '''elements''' of a '''dictionary''' using a '''for loop'''.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:39&lt;br /&gt;
| Here are some self assessment questions for you to solve&lt;br /&gt;
&lt;br /&gt;
'''Dictionary d '''is defined as shown:&lt;br /&gt;
&lt;br /&gt;
How do you retrieve the '''value 'b'?'''&lt;br /&gt;
&lt;br /&gt;
Delete '''value 'b' '''from the '''dictionary d''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 08:55&lt;br /&gt;
|And the answers,&lt;br /&gt;
&lt;br /&gt;
'''d '''''inside square brackets''''' 2 '''gives the '''value 'b''''&lt;br /&gt;
&lt;br /&gt;
'''del d '''''inside square brackets '''''2 '''deletes the '''value ‘b’'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:10&lt;br /&gt;
| Please post your timed queries in this forum. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:14&lt;br /&gt;
| Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:19&lt;br /&gt;
| FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| 09:23&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;
| 09:34&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>