ProgrammingVery hardGATE CS · Product-company placement
What is printed?
What is printed?
x = 5 print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
- A. True True False True
- B. True False False True
- C. True True True True
- D. False True False False
Correct answer: A. True True False True
Chains expand pairwise with `and`: 3 > 2 > 1 == True means (3>2) and (2>1) and (1==True), all True. The parenthesised version compares True > True, which is False. `0 == 0 in [0]` is (0 == 0) and (0 in [0]).
More Python Programming questions
- What is printed? python s = "a,b,,c," print(len(s.split(",")), len(s.split()), s.rsplit(",", 2)[0], s.partition(";")[0] == s)
- What is printed? python s = "a btcn" print(s.split(), len(s.split(" ")), len(s.strip(" ")), len(s.strip()))
- What is printed? python print("ß".upper(), "ß".casefold() == "SS".casefold(), "fi".upper(), len("ß".upper()))
- What is printed? python print("abc" -1 == "", [0] 0, "b" in "abc", "" in "abc", "abc".find(""), "abc".count(""))
- 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}")