Data Structures & AlgorithmsModerateTCS NQT Digital · Python semantics
Problem: What does the following print?
Problem: What does the following print?
print(list('abc')[::-1] == ['c', 'b', 'a'], 'abc'.index('c'))What is printed?- A. True 2
- B. False 2
- C. True 0
- D. True 1
Correct answer: A. True 2
Reversing the list gives ['c', 'b', 'a'], and 'c' sits at index 2 in 'abc'.
More Coding Interview Problems questions
- Problem: What does the following print? python x = 5 x <<= 2 x |= 1 print(x) What is printed?
- Problem: What does the following print? python print(any([]), all([])) What is printed?
- Problem: What does the following print? python print(10 20 // 10 18) What is printed?
- 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 =…