Computer Science

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')

Python Funda

1 Like

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.

Answered By

2 Likes


Related Questions