ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(str(12345)[::-1], int(str(12345)[::-1]) + 1, sum(int(d) for d in str(12345)), len(str(0)))
- A. 54321 54322 15 1
- B. 12345 54322 15 1
- C. 54321 54321 15 1
- D. 54321 54322 16 1
Correct answer: A. 54321 54322 15 1
Reversing the digit string gives 54321, and adding 1 to its integer value gives 54322. The digit sum of 12345 is 15, and str(0) has one character.
More Python Programming questions
- What is printed? python print(0o777 ^ 0o070, 0b1111 & 0xF0 | 0x0F, 1000000 // 1e3)
- What is printed? python s = 'Straße' print(s.upper(), s.lower(), s.casefold() == 'strasse', len(s.upper()))
- What is printed? python print(0.1 0.1 == 0.01, 0.1 0.1, round(0.1 0.1, 2) == 0.01)
- What is printed? python print(int(3.99999999999999999), int(-3.7), 3.99999999999999999 == 4.0, 3)
- What is printed? python s = 'x' 3 print(s -1 == '', s.replace('x', 'xy', 2), s.count('xx'), s.index('x', 1))
- What is printed? python print(' '.join(str(i) for i in range(3)), ','.join(f'{i:02d}' for i in (1, 10)), '|'.join(['x']), ''.join([''…