ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(int(' -0012 '), int('+5'), float('-.5'), float('5.'))- A. -12 5 -0.5 5
- B. 0 5 -0.5 5.0
- C. -12 +5 -.5 5.
- D. -12 5 -0.5 5.0
Correct answer: D. -12 5 -0.5 5.0
int accepts surrounding whitespace and a sign, and leading zeros are fine in base 10. float accepts '-.5' and '5.' as valid numeric strings, and both give floats.
More Python Programming questions
- What is printed? python x = 10 y = x y += 1 z = [x] z[0] += 5 print(x, y, z)
- What is printed? python a = list('abc') print(a.index('b'), ''.join(a[::-1]), a.pop(0), a)
- What is printed? python x = 5 print(f'{x=}', f'{x 2 = }', f'{"a" 2!r}')
- What is printed? python from math import ceil print(ceil(7 / 2), -(-7 // 2), (7 + 2 - 1) // 2)
- What is printed? python s = 'a b c' print(s.split(' '), s.split(), len(s.split(' ')) - len(s.split()))
- What is printed? python x = 0 for i in range(1, 9): x ^= i print(x, 5 ^ 9 ^ 5, (1 << 3) - 1 & 6)