ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(int('0b1011', 2), int('0b1011', 0), int('z', 36), int('1011', 2))- A. 11 11 35 11
- B. 11 1011 35 11
- C. 11 11 36 11
- D. 1011 11 35 11
Correct answer: A. 11 11 35 11
int with base 2 accepts an optional 0b prefix, so '0b1011' gives 11. Base 0 detects the prefix and gives the same value. 'z' is digit 35 in base 36, and '1011' in base 2 is 11.
More Python Programming questions
- What is printed? python h = 0 for ch in 'abc': h = (h 31 + ord(ch)) % 1000 print(h, (-7) % 1000, (-7 31) % 1000)
- What is printed? python print(sorted(['b2', 'a10', 'a9', 'b1'], key=lambda s: (s[0], int(s[1:]))), sorted(['b2', 'a10', 'a9', 'b1']))
- What is printed? python from math import isclose print(isclose(0, 1e-10), isclose(0, 1e-10, abstol=1e-9), isclose(1e9, 1e9 + 1)…
- What is printed? python x = 0b10110110 print(format(x, '08b')[::-1], x.bitcount(), x & (x - 1), (x & -x).bitlength())
- What is printed? python print(f'{1:>{3}}', '{0[1]}-{1!r}'.format('ab', 'cd'), '{0!r:>6}'.format('x'), '{:.1%}'.format(0.256))
- What is printed? python x = 232 + 5 print((x 0x9E3779B1) & 0xFFFFFFFF, (5 0x9E3779B1) & 0xFFFFFFFF)