Program Sample
PEP 8 : Style Guide for Python Code [www.python.org/...]
Open IDLE in an empty Edit Window.
Type in the following code. Omit the explanation text ### ... on the right.
IDLE will provide the colour coding automatically.
It will also indent after a : (colon).
# Sample ### A comment starts from a #
def sample(): ### def defines a function, here named sample.
print 'Hello' ### This is what the function does.
if __name__ == '__main__': ### There are two underscores before and after each word.
sample() ### This calls the function and so prints 'Hello'.
Running the code produces this output:
Hello