ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(''.join(sorted(set('mississippi'))), ''.join(sorted('mississippi', key=lambda c: (-'mississippi'.count(c), c)))[:3])- A. imps imm
- B. imps iis
- C. imps iii
- D. mips iii
Correct answer: C. imps iii
set removes duplicates, and sorting the four distinct letters gives imps. Sorting by descending count puts the four i's first, followed by the four s's.
More Python Programming questions
- What is printed? python print(str(1.1 1.1), str(1.21), 1.1 1.1 == 1.21, abs(1.1 1.1 - 1.21) < 1e-12)
- What is printed? python print(10 2 == 100.0, 2 0.5 2 == 2 0.25, pow(4, 0.5))
- What does ','.join([1, 2]) do in Python 3?
- Which statement about the heapq module is correct?
- What is printed? python print(sum(range(1, 10 5 + 1, 7)))
- What is printed? python print(pow(7, 222, 13), pow(7, 6, 13))