ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(int.from_bytes(b'\x01\x00', 'big'), int.from_bytes(b'\x01\x00', 'little'))
- A. 256 256
- B. 1 1
- C. 256 1
- D. 1 256
Correct answer: C. 256 1
Big-endian reads the first byte as the most significant, so 0x0100 is 256. Little-endian reads the first byte as the least significant, giving 1.
More Python Programming questions
- What is printed? python print((255).tobytes(2, 'big'), (1).tobytes(3, 'little'))
- What is printed? python print(sorted(range(10), key=lambda x: (x % 3, -x))[:4])
- What is printed? python print(''.join(sorted('banana', reverse=True)), len(set('abcABC'.lower())), 'ABC'.isupper())
- Which implementation of "count how many times each character appears in s" is the best choice in Python when len(s) = 2 10^5?
- What is printed? python from itertools import accumulate print(list(accumulate([1, 2, 3], initial=0)), next(iter(sorted({3, 1, 2}))))
- What is printed? python st = [] for t in '2 1 + 3 '.split(): if t.isdigit(): st.append(int(t)) else: b = st.pop() a = st.pop() st.append(a…