Search⌘ K
AI Features

Python Coding Style Guide and Conventions

Explore Python coding style and conventions to understand how to properly comment code, structure programs with functions, and ensure correct execution order. This lesson helps you grasp fundamental syntax and best practices to write readable and efficient Python code.

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.

Python 3.5
# 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 (''').

Python 3.5
# This is a multiline comment.
# print("Hello World")
Python 3.5
'''
This is a multiline comment.
print("Hello World")
'''

Order of execution

Not everything ...