English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Write short notes on Escape sequences with examples.

Advertisements
Advertisements

Question

Write short notes on Escape sequences with examples.

Answer in Brief
Advertisements

Solution

Escape Sequences:
In Python strings, the backslash “\” is a special character, also called the “escape” character. It is used in representing certain whitespace characters: “\t” is a tab, “\n” is a new line, and “\r” is a carriage return. For example to print the message “It’s raining”, the Python command is >>> print (“It\’s raining”)
It’s raining
Python supports the following escape sequence characters. 

Escape sequence character Description Example Output
\\ Backslash >>> print("\\test") \test
\' Single-quote >>> print("Doesn\'t") Doesn't
\" Double-quote >>> print("\"Python\"") "Python"
\n New line print("Python","\n","Lang.") Python Lang..
\t Tab print("Python","\t","Lang..") Python Lang..
shaalaa.com
Tokens
  Is there an error in this question or solution?
Chapter 5: Python - Variables and Operators - Evaluation [Page 66]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 5 Python - Variables and Operators
Evaluation | Q 4. | Page 66
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×