Comments in Python.

Python Comments:

A comment in python starts with the hash character(#). Comments are in the source code for humans to read, not for computers to execute.

Example:

#This is a comment

Types of Python comments:

1)Single lined comment

2)Multi lined comment

3)Inline comments

Single lined comment:

In case user want to specify a single line comment,then comment must start with #.

Example:

int a=10 #here a is a variable. print("Hello,world") print(a)

Output:

Hello,world 10

Multi lined comments:

Multi lined comment can be given inside triple quotes.

Example:

''' This is multiline comment in python'''

Inline comments:

If a comment is placed on the same line as a statements,it is called an inline comments. Similar to the block comments, an inline comments beigns with a single hash(#) sign and followed by a space and comment.

Example:

N=10 n+=1 # increase n by 1

Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.