Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 So you are a teacher and you wanted to calculate the average grades of your students. 1
And do we do that using this algorithm here and this data structure to store the grades. 2
The problem here is you don't know which grade is of who. 3
So while a lise is a good data structure to store an array of items, it's not good enough when these 4
items have some sort of identity attached to them. 5
In that case you want to use a dictionary. 6
Let's say student grades curly brackets. 7
That's a syntax for a dictionary. 8
And then you use names of your students. Let's say Marry, a colon. 9
Make some space or not, whatever you prefer. 10
But it's good to have a space there to make it more readable. 11
And then you write the grade of Merry. 12
Let's say Sim, 8.8. 13
John colon, 7.5. 14
So the difference between the dictionary and the list is the brackets, different brackets. 15
And then this is considered an item in a dictionary. 16
This is considered an item in a list. 17
So items in a dictionary are made of keys. 18
This is a key, and values. 19
This is a value. A list would be more appropriate if we had to store for example an array of temperature values. 20
Let's say Monday had these temperatures. Monday temperatures. 21
And lastly how do we calculate the average when we have a dictionary? Since these are pairs of keys 22
and values. 23
You can't just make the sum like that. 24
You need to specify the sum of what you want to get. 25
So student grades and if you check dir dict for dictionary, you'll see that dictionaries have these 26
values which is a method, dict.values it is a method and it provides a view of a dictionary of values. 27
In simple words 28
it gives you the values of a dictionary. 29
So if you get this dictionary, Q for quit here, paste it here, and see student_grades.values and that 30
will give you this data type. 31
So it's still a data type. 32
It does look like at list, it's not exactly a list, but it behaves like a list with these three values 33
there. 34
So it's a dict values type. 35
That method produces this type and therefore you can add that in there. 36
Don't forget the parentheses. 37
Don't forget to save. 38
And don't forget to execute to give the output and this is the average value of a dictionary of values. 39
To get the keys of a dictionary 40
just do keys and you get this dict keys type with the keys of the dictionary as items of that dict keys 41
arrays.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.