#100DaysOfCode in Python Transcripts
Chapter: Appendix: Python language concepts
Lecture: Concept: The shape of a program
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
One of the unique concepts in Python is to minimize the number of symbols and control structures in the language.
0:09
For example, in C and C-based languages like C# and JavaScript, you have lots of curly braces, and variable declarations and so on,
0:17
to define structures and blocks. In Python, it's all about the white space, and indentation. So here we have two particular methods,
0:27
one called main and one called run and they both define a code block and the way you do that is you say define the method, (colon),
0:35
and then you indent four spaces. So the purple blocks here these are also code blocks and they are defined because they are indented
0:43
four spaces the "if" and the "else" statement. But within that "if" statement, we have a colon ending it,
0:47
and then more indentation, and that defines the part that runs in the "if" case, and then we have the "else" unindented, so that's another piece,
0:55
another code suite or block, and then we indent again to define what happens when it's not the case that the argument is batch or whatever that means.
1:03
And we saw that these are spaces, the convention is to use four spaces for each level of indentation, it's generally discouraged to use tabs.
1:11
Now, if you have a smart editor that deeply understands Python, like PyCharm or Sublime text or something like that,
1:17
it will manage this indentation and those spaces for you, so it's much, much easier in practice
1:23
than it sounds before you actually get your hands on it.