In Python, indentation is used to represent blocks.
Also, the line ending with a colon (:) marks the beginning of the block.
if num == 1:
print "One."
elif num == 2:
print "Two."
else:
print "N/A."
Shebang
As Shebang, write the following on the first line of the Python script.
#!/usr/bin/env python
Coding Style
Coding Style refers to PEP 8. PEP 8 is a Style Guide for Python compiled by the Python Community.
PEP 8 - Style Guide for Python Code https://www.python.org/dev/peps/pep-0008/
There is also a Japanese translation. http://pep8-ja.readthedocs.org/ja/latest/
--Indentation is "4 spaces" --Use lowercase letters and underscores for method names --Use lowercase letters and underscores for instance variables --Use uppercase letters and underscores for constant names
sample.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
num = 5
for i in range(num):
print i, ": Hello!"