ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(not 1 == 2, not (1 == 2) is True, (not 1) == 2, 1 + True + True)
- A. False True False 3
- B. True False False 3
- C. True True False 1True
- D. True True False 3
Correct answer: D. True True False 3
`not` has lower precedence than comparisons, so `not 1 == 2` is not (1 == 2) = True. `not (1==2) is True` is not (False is True) = True. (not 1) is False, which is not 2. bools add as 0/1.
More Python Programming questions
- What is printed? python x = 5 print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
- 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))