Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
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
Welcome back.
In this video, we'll go over comments in Python.
I am creating a new script.
Guido van Rossum, the creator of Python, once said that code is more often read than written.
When working with any programming language, you should include comments in the code to notate your
work.
This documents what certain parts of the code are for and lets other developers, you included, know
what you intended to do when you first wrote the code.
This is a very good practice in any programming language, and good developers make heavy use of comments.
Without them, things can get really confusing, especially in complex projects.
Comics in Python.
Start with the hash character and extend to the end of the line.
A comment may appear at the start of a line or following the code.
Comments are for clarifying code and are not interpreted by Python.
Let's see some examples.
This is a comment.
It's recommended to add a whitespace after the hash symbol for readability.
Hash A equals five.
This line is another comment.
X equals nine.
And I'm adding an inline comment here.
I create a variable called x.
That store's an integer.
A hash character within a string.
Literal is just the character, not a comment.
For example, my star equals a hash and I'm adding a hash character within a string.
Literal.
This is a string.
Literal is just a hash character.
It's not a comment.
In other programming languages, there are ways to comment out an entire block of code here in Python.
If you want to comment out multiple lines, you need to prefix each line.
You want to comment out with a hash sign.
I'm adding a few more lines of code.
In picture.
After selecting the code, you want to comment out press control and for backslash.
And it will comment out the entire block of code by commenting out each individual line of that block
of code.
And if you select that block of code again and press control and for backslash, it will uncomment it.
I am pressing control.
And for Slash.
Sometimes you might see something like this.
Triple quotes and some python code in between.
X equals ten.
Print x.
I'm running the script.
It didn't print the value of X.
Even though that's not interpreted by Python and is basically like a comment, it's not actually one,
but rather a docstring and recommendation is to not use this syntax for comments.
Doc strings are used for documentation and we'll talk about them later in the course.
The excel about comments in Python.
In the next video we'll talk about constants.
Thank you.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.