Python Coding Style Guide and Conventions
Let's look at some guidelines and tips for creating good Python code.
We'll cover the following...
Commenting
Comments are one of the most important parts of your code because they give you an idea of what exactly your code is supposed to do.
In Python, single line comments begin with a hash mark, #
, and continue to the end of the line.
Press + to interact
# This is a Comment# This is an Another Comment# print("Hello, World!")
Although there isn’t any specific syntax for multi-line comments in Python, you can either insert a hash mark for each comment line or use triple-quoted strings ('''
).
Press + to interact
# This is a multiline comment.# print("Hello World")
Press + to interact
'''This is a multiline comment.print("Hello World")'''
Order of execution
Not everything ...