ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(list('abc'.encode()), 'abc'.encode()[0] + 1, bytes('hi', 'ascii') == b'hi')- A. [97, 98, 99] 98 False
- B. [97, 98, 99] 98 True
- C. [97, 98, 99] 99 True
- D. [97, 99] 98 True
Correct answer: B. [97, 98, 99] 98 True
Iterating over a bytes object gives ints, so the code points 97, 98 and 99 are printed. Indexing gives the int 97, and bytes built from ASCII text equal the matching b'' literal.
More Python Programming questions
- What is printed? python x = 17 print(x.bitlength(), (x & -x).bitlength(), x.bitcount(), bin(x)[2:].zfill(8))
- What is printed? python print(int(2.5 4) // 3, int(10 / 4 2), 10 // 4 2, 10 / 4 // 2)
- What is printed? python print(float(1) / 3 + float(2) / 3 == 1.0, 0.1 0.1 100 == 1.0, 1 - 0.1 9 == 0.1)
- What is printed? python print(f"{0.1:.20f}")
- What is printed? python def nge(a): st, res = [], [-1] len(a) for i, x in enumerate(a): while st and a[st[-1]] < x: res[st.pop()] = x…
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 4, 6, 7, 9] print(list(takewhile(lambda x: x % 2, a))…