ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
x = 2**32 + 5 print((x * 0x9E3779B1) & 0xFFFFFFFF, (5 * 0x9E3779B1) & 0xFFFFFFFF)
- A. 387276917 387276917
- B. 387276917 3907690379
- C. 2654435761 387276917
- D. 387276918 387276917
Correct answer: A. 387276917 387276917
Masking with 0xFFFFFFFF keeps only the low 32 bits, and 2**32 contributes nothing to those bits. So the two expressions agree, and 5 * 0x9E3779B1 is 387276917 modulo 2**32.
More Python Programming questions
- What is printed? python import math print(math.factorial(20) // 106 % 1000, len(str(math.factorial(30)))…
- What is printed? python print(float('0.1') == 0.1, float(' 0.1 ') == 0.1, 0.1 == float(str(0.1)), 1e23 == 1023)
- What is printed? python total = 0 for s in ['10', '9', ' x', '+7', '10']: try: total += int(s) except ValueError: total -= 1 print(total)
- What is printed? python print('%d' % 3.9, '%d' % -3.9, '%.0f' % 0.5, '%i' % True)
- What is printed? python s = 'héllo' print(s[1], s.encode('latin-1')[1], len(s.encode('utf-16-le')), s.isascii())
- What is printed? python from decimal import Decimal, getcontext getcontext().prec = 4 print(Decimal(1) / Decimal(3), Decimal('1.10') ==…