Page Nav

HIDE

Grid

GRID_STYLE

Classic Header

{fbt_classic_header}

Header Ads

//

Breaking News

latest

Comments, Escape, Sequence, Print Statement in Python

  Comments, Escape, Sequence, Print Statement in Python Comments, Escape, Sequence, Print Statement are used to write something which the pr...

 Comments, Escape, Sequence, Print Statement in Python


Comments, Escape, Sequence, Print Statement are used to write something which the programmer dose not want to execute, comments can be written to mark author name, date when the program is written
ending nots for your feature self etc.
  • Comments are used to make the code more understandable for the programmer.
  • The Interpreter dose not execute comments there are two type of comments in python language.

  1. what is single line comment in python

  1. what is multiline comment in python

what is single line comments in python

 single line comment are the comments which are written in a single line i.e they occupy space of a single line

we use #(hash to written single line comments.)

 eg.the below program depicts the using of comments.

 

hello world program in python

#this is hello world program

print("hello world") 

hello world program output in python





what is multi line comments in python

multi line comments are the comments which are crated by using multi-line i.e the occupy more then one line in a program.



how to add multiline comment in python

program:-

""" this 

is

multi line

comment"""

print("hello world")

multiline comment output in python





what is print() statement in python

print() is a function in python that allow us to display whatever is written inside it. In case an operation is supplied to print, the value of the expression after the evaluation is printed in terminal.

how to add print statement in python with program

program:-

import os
import flask
#print statement for print strings
print("hello world")
"""
this will
print
hello world"""

print statement output in python





what is end statement in python

end arguments allow us to put something at the end of the line after it is printed. In some words, it allow us to continue the line with ""  "" or "," anything we wont to put inside these quotes of end. It simply joins to different print statement using some string or even by space.

how to add end statement in python

program:-

print("hello world", end="**")

end statement output in python



what is Escape sequence in python

  • An escape sequence character in python is sequence of characters that represents a single character.
  • It don't represent it self when used inside string literal or character.
  • It is composed of two or more characters strings with backslash\ but act as a single character. Example \n depicts a new line character.

list of all escape sequence in python

 \n    :- insert a new line in the text at that point.

\\    :- insert the backslash character in the text at the point.

\"    :- insert the double quote in the text at the point.

\'    :- insert the single quote in the text at the point.

\t    :- insert the tab in a text at the point.

\f    :- insert a from feed in the text at the point.

\r    :- insert a carriage return in the text at the point.

\b    :- insert a backspace in the text at the point.


escape sequence program in python

print("hello\n world\t")

 


escape sequence program output in python





No comments

please do not enter any spam link in the comments box.