3.1.2. Comments, Strings and Print Statements Comments

  • Non-computational parts of the program that textually describe the behaviour of the program.

  • Comments begin with # everything to right of the hash is ignored by Python.

  • Comments should be frequent so you and others can understand the code.

# Did you notice that these words are green? Any words after
# a Hash Tag (#) on the same line are called comments.

# Comments are lines of code that the computer does not
# look at. These can be used to clarify the purpose of your
# code and make it easier to read. Strings

  • Sequence of characters enclosed by a pair of single or double quotes

  • Examples are “cats hate dogs” and ‘Strings are fun!’.

  • Strings are one kind of data in Python. Their data type is denoted str.

print "This is a string"
This is a string
print 'This is also a string'
This is also a string