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 Now when it comes to naming your variables, 1
you can pretty much call it whatever it is you want. 2
So instead of calling this name, 3
I could have just called it n and I could have called this l and as long as I'm 4
consistent. 5
So if I wanted to get the length of N then I would have to change this as well. 6
And if I wanted to print out L then I have to change this as well. 7
But there's a couple of rules that you should probably follow. 8
And the most important one is to make your code readable. Because if you come 9
back to this in six months, 12 months, 10
N and L is not going to have a lot of meaning for you. 11
So try to make sure that it actually makes sense to you. 12
And if you want to, 13
you can actually have multiple words in the name of your variable. 14
So for example, if you wanted to call this username, 15
then you would write the word user and then you would separate each of the words 16
with an underscore. But you can't have a space in between. 17
This is not valid code and if you try to run it, you'll get a syntax error. 18
So the name of the variable has to be one single unit and in order to separate 19
words in Python, we use the underscore. 20
Now if you want to use numbers in the name of your variable, 21
you can. So for example, length1, 22
length2. But they can't be at the beginning of the name of the variables. 23
You can't say 1length or 3length. 24
That will generate a syntax error as well. Finally, 25
there's certain privileged words that we use, for example, 26
the names of our functions like print and input. 27
And it's usually good practice to not use them as the names of your variables 28
because you can see that syntax highlighting gets messed up because it thinks 29
that is actually input function you're trying to create. 30
And even though often when you run your app, it might not have any issues, 31
this is really bad practice because it's very confusing. 32
So try to make sure that all the names of your variables get highlighted, 33
like the other variables in the same color. Now, 34
the final thing to remember is that if you decide to call your variable this 35
particular name, n-a-m-e, and at a later point you make a typo and you spell it 36
wrong, so maybe instead of name you said nama, 37
this is not going to work and when you run your code you'll get what's called a 38
name error because it says this name is not defined. And the idea is that you 39
would look at where the error is, line 2, print nama and you'll see, 40
Oh that's not right. It's meant to be spelled n-a- 41
m-e. So you'll have to go and fix it in order for your code to work. 42
Now remember that this is not because Python is doing any sort of spell-checking 43
for you. It's like, Oh, that's not how you spell name. No. In fact, 44
if you decided to call this nama and you, later on, used it as name, 45
there's no problems, there's no issues, no errors,. 46
As long as it's consistent, 47
this is the name that's associated with this piece of data. Later on, 48
when you want to use this piece of data, you use this name to refer to it. 49
And as long as these two spellings are identical, 50
then the computer doesn't care at all. 51
So when you get a name error in your code, 52
you now know it's probably because you've misspelled or mistyped one of the 53
variable names somewhere in your code. Now in the next lesson, 54
I prepared a quiz for you where you'll get to select which variable names are 55
valid and which ones are not good practice. 56
Have a go at that over on the next lesson.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.