Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.37 KB

P3- Writing comments in Python.md

File metadata and controls

41 lines (27 loc) · 1.37 KB

A comment is a statement which is not executed by the interpretor. It's simply avoided by the interpretor.

Contents

Single-Line Comment

Multi-Line Comment

Applications of Comments

Single-Line Comment-

A single-line comment can be implemeted by using a # (hashtag) symbol.

# A python program to show implementation of a single-line comment
# This is a single line comment

Multi-Line Comment-

A multi-line comment can be implemeted by using a ''' ''' symbol.

'''A python program to show implementation of a multi-line comment
This is a multi-line comment'''

A comment can also be written alongside a statement to write its explanation etc.

x = 5
print(str(x))  # printing 'x' as a string rather than an integer

Applications of Comments-

  1. Adding what the program is about
  2. Adding explanatory note of a source code
  3. Comment a part of the code during testing
  4. Adding a plan regarding the design of a source code