1.

Which of the following statement prints hello\example\test.txt?(a) print(“hello\example\test.txt”)(b) print(“hello\\example\\test.txt”)(c) print(“hello\”example\”test.txt”)(d) print(“hello”\example”\test.txt”)The question was asked by my college professor while I was bunking the class.This is a very interesting question from Strings in portion Strings of Python

Answer»

Right OPTION is (b) print(“hello\\example\\test.txt”)

The BEST EXPLANATION: \is used to indicate that the NEXT \ is not an escape SEQUENCE.



Discussion

No Comment Found

Related InterviewSolutions