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(""))- A. True [] True False -1 0
- B. ValueError [] True True 0 3
- C. True [] True True 0 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
- What is printed? python print("%s|%r|%.3s|%5.2e|%o" % ("a", 1.0, "python", 1234.5, 8))
- What is printed? python w = 7 print(f"{'x':>{w}}|{3.0:g}|{1e-5:.0e}|{0.5:.0%}|{-3:+d}|{12:08b}")
- What is printed? python print(int(True), int("0b101", 0), int("0o17", 0), int("ff", 16), int(" 12n"), int(" 0x10 ", 16))
- What is printed? python from fractions import Fraction as F from decimal import Decimal as D print(F(1, 3) + F(1, 6), D("0.1") + D("0.2")…
- What is printed (Python 3.12 or later)? python from functools import reduce xs = [0.1] 10 print(sum(xs) == 1.0, reduce(lambda a, b: a + b…
- What is printed? python nan = float("nan") print(max(nan, 1), max(1, nan), min(nan, 1), nan in {nan})