ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(sum(1 for c in 'a1 b2_' if c.isalpha()), sum(1 for c in 'a1 b2_' if c.isdigit()), sum(c.isspace() for c in 'a1 b2_'))
- A. 2 2 0
- B. 2 1 1
- C. 3 2 1
- D. 2 2 1
Correct answer: D. 2 2 1
Two letters, a and b, and two digits, 1 and 2, are present. The underscore is neither a letter nor a digit, and the space is the only whitespace.
More Python Programming questions
- What is printed? python print(round(2.675, 2), round(2.665, 2), round(1.0049999999999999, 3), round(-2.5, 0))
- What is printed? python print(max('apple', 'banana', key=len), max(['x', 'yy', 'zz'], key=len), min([3, 1, 1.0], key=abs), max([1, 1.0]…
- What is printed? python print(float('0.1') + float('0.2') == 0.3, float('0.30000000000000004') == 0.1 + 0.2…
- What is printed? python s = 'hello' print(s.index('l'), s.rindex('l'), s.find('z'), s.count('l'))
- What is printed? python print(int(str(264) 0 + '7') 2, len(str(7 100)), 7 100 % 10)
- What is printed? python from itertools import product print(list(map(''.join, product('ab', repeat=2))))