Data Structures & AlgorithmsModerateTCS NQT Digital · Python semantics
Problem: What does the following print?
Problem: What does the following print?
print(10 ** 20 // 10 ** 18)What is printed?
- A. 1000
- B. 10
- C. 10000
- D. 100
Correct answer: D. 100
10**20 // 10**18 = 10**2 = 100 exactly, because Python integers do not overflow.
More Coding Interview Problems questions
- Problem: What does the following print? python print(float('inf') > 10 100, -0.0 == 0.0) What is printed?
- Problem: What is the 1-indexed survivor when n = 6 people stand in a circle and every 3rd person is removed? Run the recurrence code…
- Problem: What is the length of the longest run of equal consecutive characters in 'aabbbbcc'? Run the code. python s = 'aabbbbcc' best =…
- Problem: How many subsets of {1, 2, 3, 4} have a prime sum (the empty set has sum 0 and is not prime)? Run the code. python from itertools…
- Problem: How many ordered pairs (i, j) with i != j of [1, 2, 3, 4] have an even sum? Run the code. python a = [1, 2, 3, 4] print(sum(1 for…
- Problem: What does the following print? python from collections import Counter print(Counter('mississippi').mostcommon(1)) What is printed?