Comments and Escaping Sequence

 #To insert any character that cannot be added into the print function directly, we use escape sequence character "\"

print("Hey I am Sindhu\nand I am a good girl")   #output- Hey I am Sindhu   

                                                                                              and I am a good girl

# \n is an escape sequence character which is used to change the line. No need for a space after \n

print("She said, \"Python is awesome!"")    #Double quotes inside the string

output = She said, "Python is awesome!"

#We use escape sequence character to print double quotes inside print () function which cannot be used directly.

'''

If we use # in front of a line then it will be a comment and it will not be executed

ctrl+/ is used to comment uncomment the line

A comment is a part of the coding file that the programmer does not want to execute, rather the programmer uses it to either explain a block of code or to avoid the execution of a specific part of the code while testing.

'''

'''

print(" I am Sindhu")

print(" I am a good girl")

'''

#triple single quote or triple double quote is used to comment multiple lines.

'''To insert characters that cannot be directly used in a string, we use an escape sequence character.

#An escape sequence character is a backslash \ followed by the character we want to insert.

'''

print("Hey I am a \"good girl\"")             #output- Hey I am a "good girl"

'''An example of a character that cannot be directly used in a string is a double quote inside a string that is surrounded by another double quote.

'''

#print("This will not be "execute")

#print("This will be \"execute\"")

print("Hello", 24, 9)                               #output-Hello 24 9

# We can use multiple values in print statement.

print("Hello",24,9, sep="~")                        #output-Hello~24~9

#sep is used to separate the vales of print statement.

print("Hello",24, 9, sep="~", end="2002")           #output-Hello~24~92002

#end is used to end the print statement with a specific value


Comments

Popular posts from this blog

Print Function

Arithmetic Operators

Sets in Python