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 This function returns the mean value of a list, but we want to make it more intelligence. 1
We want the function to return to the mean even if the input value is a dictionary. 2
So when the input value is a list it will going to apply a specific algorithm and return the specific 3
value which is the mean of a list. When it's a dictionary 4
it's going to check if it's a dictionary and apply the corresponding algorithm that calculates the mean 5
value of a dictionary. 6
So we know that 7
sum(monday_temperatures) divided by length of monday_temperatures gives you the mean of the list. 8
Similarly student grades which is a dictionary, it's values, the sum of its values divided by the length 9
of student grades dictionary will give you that mean. 10
So we want our function to check and make a decision. 11
This is a parameter. 12
Let me change it to value. 13
Value is a more meaningful name since what we are processing we will not only be a list but it can 14
also be a dictionary. 15
And then under the function everything has to be indented. 16
You can see the whole body of the function is indented. 17
So the conditional block that I'm going to write here is also going to be indented. 18
It starts with if. If you remember we used a type function earlier in the course which returned the type 19
of an object. 20
For example this is a dictionary, an empty one, but it's still a dictionary. 21
So what you can do here is you can say if type value. 22
Double assignment operator which means equal. 23
It's a comparison operator. 24
It checks equality. If that is a dict, a column, enter and it has to be indented with four spaces. 25
So you see it's another level of indentation it's one here for if, and this is for the function, so here 26
the mean will be equal to sum of value 27
dot values 28
divided by the length of value. 29
So this is a dictionary dict.values and length of the dictionary. 30
I have to close the sum function call there like that and enter. 31
If you are done with 32
the if block, 33
so if that's all what you want to check then you say else 34
and we have this code which has to be indented under else as well and that's it. 35
Let me try this. So with student grades, the dictionary as input 36
we got these value here. 37
If I used 38
the list 39
monday_temperatures it's going to give me the other value which is the meaning of the Monday temperatures. 40
So that's an if and else conditional. 41
But let me explain it line by line in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.