Comments, Escape sequences and print statement
Print statement
print("Subscribe now")
Here we used print function to print the statement as it is, Hence print function is only used for to print the the sentences or statements in program to make it clear for the user.
Comments
Comments are used to Commenting or used to remember the line of programe which is used in main, It basically helps to remind the meaning of the line and it will never run with main program it will ignored by it, Comments are generally two types in python👇
Single line comment
multi line comment
move to code👇
# this is a single line comment
"""this
is
a
multi
line
comment"""
With every new print function will gives new line for the statement, If u want that new line will don't get print then add the [, end=" "] It will the new line of print to the first print statement.
Comment must be used after from the print statement or before it will never works inside the print statement, wear as print statement will print that comment line also with # or """
code👇
print("hello python")
print("hello how are you, end="")
In between you can add any word, white spacing or statement by entering the characters between the double quotes👇
(end= "you can add here anything")
Escape sequences
Escape sequences are used to make some changes into the print statement during the program like entering in new line, make a alarm or a beep sound the the device.
code👇
print("c:\narry")
Here the statement will be print as arry because here we use \n before arry in escape sequences (\n) means new line character, Hence the arry will print in another line whereas (c:) will be printed in the first line as normal.
Here are some escape characters used in Python👇
Code |
Description |
\’ |
Single Quote |
\\ |
Backslash |
\n |
New Line |
\r |
Carriage Return |
\t |
Tab |
\b |
Backspace |
\f |
Form feed |
\ooo |
Octal Value |
\xhh |
Hex Value |
Comments
Post a Comment