ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(float('1_000.5'), end=' ')
try:
int('1__0')
except ValueError:
print('VE')- A. 1000.5 VE
- B. 1000.5 ValueError
- C. 1000 VE
- D. 1_000.5 VE
Correct answer: A. 1000.5 VE
Underscores are allowed between digits in float and int literal strings, but not two in a row. Here float('1_000.5') is 1000.5, and int('1__0') raises ValueError.
More Python Programming questions
- What is printed? python d = {1: 1} try: for k in d: d[k + 1] = 0 except RuntimeError as e: print(e)
- What is printed? python print([sum(i for i in range(3) if m >> i & 1) for m in range(8)])
- What is printed? python from functools import reduce import math print(reduce(math.gcd, [12, 18, 24]), reduce(math.lcm, [4, 6, 10]))
- What is printed? python people = [('ann', 25), ('bob', 30), ('cy', 25), ('dan', 30)] people.sort(key=lambda p: p[0])…
- What is printed? python print(-5 // 2 2 + -5 % 2 == -5, 5 // -2 -2 + 5 % -2 == 5)
- What is printed? python a = [1, 2, 3] a.append(a) print(len(a), a[-1][-1][0])