ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
print("abc" * -1 == "", [0] * 0, "b" in "abc", "" in "abc", "abc".find(""), "abc".count(""))
  1. A. True [] True False -1 0
  2. B. ValueError [] True True 0 3
  3. C. True [] True True 0 4
  4. D. True [] True True 0 3

Correct answer: C. True [] True True 0 4

Multiplying a sequence by a negative number gives an empty one. The empty string is a substring of every string: find('') is 0, and count('') counts the len+1 = 4 gaps.

More Python Programming questions

Exams that ask this topic