ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
x = 'abc' y = x.upper() z = x.upper().lower() print(y, z == x, x.upper().upper() == y, len(y + z))
- A. ABC False True 3
- B. abc True False 6
- C. ABC True True 3
- D. ABC True True 6
Correct answer: D. ABC True True 6
upper() gives ABC, and lower() of that matches the original abc, so the comparison is True. The second upper() call gives ABC again, and the two strings together have six characters.
More Python Programming questions
- What is printed? python print(int('0009'), float('009.50'), int(' -0 '), str(-0))
- What is printed? python print(len(str(2 64)), str(2 64)[:4], 2 64 % 1000)
- What is printed? python print('%c%c' % (72, 105), chr(0x263A) == 'u263a', ord('A') + 1, chr(ord('a') + 25))
- What is printed? python print(sum(i i for i in range(10)), sum(range(10)) 2 == sum(i 3 for i in range(10)), sum(range(10)) 2)
- What is printed? python print(f'{3.14159:.2}', f'{"abc":.2}', f'{0.5:.0%}')
- What is printed? python from fractions import Fraction print(Fraction(1, 2) + 0.5 == 1, Fraction(1, 3) 3 == 1, type(Fraction(1, 2) +…