ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print('xxhixx'.strip('x') + '|' + 'abc'.strip('ac'))- A. xxhixx|b
- B. hi|b
- C. hi|abc
- D. hi|ac
Correct answer: B. hi|b
strip with an argument removes any of the listed characters from both ends. The x characters go from the ends of xxhixx, and a and c are removed from abc, leaving b.
More Python Programming questions
- What is printed? python print(len(str(2100)), str(2100)[:5])
- What is printed? python print(sorted([[2, 'b'], [1, 'z'], [2, 'a']]))
- What is printed? python x = [1, 2, 3] y = x.copy() y.append(4) print(len(x), len(y), x is y)
- What is printed? python print('aaa' < 'b', 'abc' > 'abd')
- What is printed? python print(sum(1 for c in 'hello world' if c in 'aeiou'))
- What is printed? python print(list(filter(lambda x: x > 0, map(lambda x: x - 2, [1, 2, 3, 4]))))