G-10 Lesson-1(Pep 8 Standards) Answer Key
G-10 Lesson-1(Pep 8 Standards) Answer Key
G-10 Lesson-1(Pep 8 Standards) Answer Key
1. Linter Flake 8
5. Characters in a line 79
2. What is linting?
Linters are programs that analyze source code for symantec
discrepancies and flag errors.
4. What is flake 8?
Flake 8 is a linting tool.
def main():
name = input("Enter your name: ")
greet(name)
if _name_ == "_main_":
main()
In the above example, we have used vertical spaces to separate the
function definitions from each other, making it clear where each
function starts and ends. We have also used a vertical space to
separate the main function from the if _name_ == "_main_": block,
making it clear that the main function is the entry point of the
program. By using vertical spaces to separate different parts of the
code, we can improve its readability and make it easier to
understand.
4. What is flake 8? How can you install and use flake 8? Explain
with examples.
Flake8 is one of the linting tools available. It is a great toolkit for
checking your code base against.
coding style (PEP8) and programming errors (like “library imported
but unused” and "Undefine
name”).
Use the following command to install flake8.
python<version> -m pip install flake8
Running flake8:
● Check particular file
○ flake8 path/to/code/code.py
Inline comments:
● Use inline comments sparingly.
● Write inline comments on the same line as the statement
they refer to.
● Separate inline comments by two or more spaces from the
statement.
● Start inline comments with a # and a single space, like block
comments.
● Don't use them to explain the block.
Docstrings:
● Surround docstrings with three double quotes on either side.
Ex: “”This is a docstring”””.
● Write docstrings for all public modules, functions, classes,
and methods.
● Put the “"" that ends a multi-line docstring on a line by itself.