CBSE Class 12 Computer Science Question 32 of 105

Python Revision Tour — Question 16

Back to all questions
16
Question

Question 16

Which of the following four code fragments will yield following output?

Eina 
Mina 
Dika

Select all of the function calls that result in this output

  1. print('''Eina
    \nMina
    \nDika''')
  2. print('''EinaMinaDika''')
  3. print('Eina\nMina\nDika')
  4. print('Eina
    Mina
    Dika')
Answer

print('Eina\nMina\nDika')

Reason

  1. print('''Eina
    \nMina
    \nDika''') — It is a multiline string and by adding \n extra line will be added.
  2. print('''EinaMinaDika''') — There is no new line character.
  3. print('Eina\nMina\nDika') — It adds new line by \n new line character.
  4. print('Eina
    Mina
    Dika') — It creates an error because it is a multiline string with no triple quotes.