ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 7 print(x // 2 if x % 2 else x / 2, x > 3 > 2, not x > 3 == 4)
- A. 3.5 True True
- B. 3 False False
- C. 3.5 False True
- D. 3 True True
Correct answer: D. 3 True True
7 is odd, so the conditional gives 7 // 2 = 3. The chained comparison x > 3 > 2 means x > 3 and 3 > 2, which is True. The comparison x > 3 == 4 is the chain (x > 3) and (3 == 4), which is False, so `not` of it is True.
More Python Programming questions
- What is printed? python print(pow(-2, 3, 5), pow(3, -1, 7), pow(2, 10, -7), (-2) 3 % 5)
- What is printed? python try: s = str(10 4301) print(len(s)) except ValueError: print('too many digits')
- What is printed? python print(' xt'.strip() == 'x', 'atb'.expandtabs(4), len('atb'.expandtabs(4)), 'abrncd'.splitlines())
- What is printed? python print('²'.isdigit(), '²'.isdecimal(), '²'.isnumeric(), '٥'.isdecimal())
- What is printed? python print(len('é'.encode('utf-8')), len('é'.encode('utf-16-le')), len('a€'.encode()), b'xc3xa9'.decode())
- What is printed? python print(f"{12:>{5}}|{3.14159:.{2}f}|{'ab':^6}")