Comments

Coding: Introduction to Python v3, topic 4.2.1

Comments

Comments are lines of code that are ignored completely by the computer.

What are comments?

What are comments?

  • A comment is a line of code that is completely ignored by the computer.
  • Comments can be used to add description to your code to make it easier for other people to understand.
  • They can also be used to leave notes and reminders to yourself as you work on a complex program.
How to comment

How to comment

  • To write a comment in most languages, you must use a special character which tells the computer to ignore the rest of the line:
  • In Python, that character is a #.
Interfaces

Interfaces

  • An interface is a collection of comments which describe a subroutine.
  • An interface includes:
  • List of parameters and their types.
  • Return value and its type.
  • What the subroutine does.
Interface example

Interface example

Test yourself on Comments

  • How do you start a single-line comment in Python?

Practise this topic for free