ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
def f(s):
return s[::-1] == s
print(f('abba'), f('ab' * 2), f(''), f('a'))- A. True True True True
- B. True False True True
- C. True False False True
- D. False False True True
Correct answer: B. True False True True
abba reads the same backwards, and so does the empty string and a single character. 'abab' is not a palindrome.
More Python Programming questions
- What is printed? python print(True + True, str(True) + '1', str(None), str([None]), repr('None'))
- What is printed? python print(sorted([0.5, -0.0, 0.0, -1]))
- What is printed? python x = 10 16 print(float(x) == x, float(x + 1) == x, x + 1.0 == x, (x + 1) - x)
- What is printed? python print('%5s|%-5s|' % ('ab', 'cd'))
- What is printed? python print(len('%-8.3f|' % 3.14159), len('%08.3f' % -3.14159), '%08.3f' % -3.14159)
- What is printed? python import math print(math.prod([]), math.prod(range(1, 6)), math.lcm(range(1, 6)), math.lcm())