ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
x = 5 print(x.__add__(3), (5).bit_length(), 5 .real)
- A. 8 3 5.0
- B. 2 3 5
- C. 8 3 5
- D. 8 1 5
Correct answer: C. 8 3 5
int.__add__ is the method behind +, so it returns 8. 5 needs 3 bits, and the real part of an int is the int itself.
More Python Programming questions
- What is printed? python print({{'a': 1, 'b': 2}, 'a': 3})
- What is printed? python a, b, c = [1, 2, 3, 4] print(a, b, c)
- What is printed? python print(12 & -12, 12 & 11, ~12 & 0xF)
- Which loop builds a list of n items in total O(n^2) time in CPython, because each step copies the whole list?
- What is printed? python s = {1, 2, 3} s |= {3, 4} s.discard(9) print(sorted(s), 4 in s, len(s))
- What is printed? python nums = [5, 3, 8] nums2 = nums nums += [1] nums3 = nums[:] nums3.pop() print(nums2, nums3)