ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(int('12abc', 36), int('zz', 36), int('-z', 36))- A. 1786296 1295 -35
- B. 1786296 1295 -36
- C. 1786296 1296 -35
- D. 1786297 1295 -35
Correct answer: A. 1786296 1295 -35
Base 36 uses digits 0 to 9 then a to z. 12abc works out to 1786296, zz is 35 * 36 + 35 = 1295, and -z is -35 because the sign applies to the whole number.
More Python Programming questions
- What is printed? python print(hash(-1) == hash(-2), hash(-1), hash(261 - 1))
- What is printed? python print(int.bitlength(-255), (255).bitlength(), (256).bitlength())
- What is printed? python print(chr(0x1F600) == '😀', len('😀'), len('😀'.encode('utf-16-le')))
- What is printed? python print(10400 > float('inf'), float('inf') > 10400, float(10308) == 10308)
- What is printed? python print('ab' in ['a', 'ab'], 'ab' in 'a,ab'.split(','), 'a' in 'abc' and 'ac' in 'abc')
- What is printed? python print(f'{-5:x}', f'{-5 & 0xF:x}', hex(-255), format(255, '#010b'))