Question-12:  If you want to print a special character like “’” apostrophe as part of string, how can you achieve that?

  1. Using Keyword
  2. Using a variable
  3. Using escape character
  4. Using double quote

 

Answer: C

Exp :

  • “\n” python would consider it is a single character.
  • “\” is known as escape character.
  • It helps in adding new line in a string.
  • How to print “\” itself. You have to escape it.
  • Similarly for “\’” printing single quote as part of String

Strings

  • String always needs a double quote.
  • If your string itself require quotes then?
  • We already discussed escape character
  • Or use apostrophe to create your string.
  • If you want only one apostrophe in string, you have to escape it.

print("Learning Python from \"HadoopExam.com\"")

print('Learning Python from "HadoopExam.com"')

print("Learning Python from 'HadoopExam.com'")

print("Wow\' HadoopExam is nice")

 

 

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam