1.12. Comments#

As you begin to write longer and longer programs, it’s often helpful to write notes in your code. These are called comments. A comment is meant to be a short note explaining a section of code to the programmer, and is ignored by the computer. There are two types of comments.

  1. # Single line comments
    
  2. """
    Multi-line
    comments
    """
    

Here are some examples:

1.12.1. Single line comment#

x = 4
y = x**2  # squares x
n = input("Enter a number:")

# Convert string to integer
n = int(n)

print(n + 5)

1.12.2. Multi-line comments#

"""
This program takes two numbers from the user
and then outputs the sum.
"""

x = float(input("Enter a number: "))
y = float(input("Enter another number: "))

print("The sum of your numbers is {}".format(x + y))