ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(int(3.99999999999999999), int(-0.9))
- A. 4 0
- B. 3 0
- C. 4 -1
- D. 3 -1
Correct answer: A. 4 0
The literal 3.99999999999999999 is rounded to the double 4.0 before int sees it, so int gives 4. int truncates toward zero, so int(-0.9) is 0.
More Python Programming questions
- What is printed? python print('{0}{1}{0}'.format('a', 'b'), '{:>3}'.format(7), '%%%d' % 5)
- What is printed? python print(bin(5 << 2), 5 >> 1, -5 >> 1, -5 // 2)
- What is printed? python print(1 if 0 else 2 if 3 else 4, 0 or '' or 'z', 0 and 'z')
- What is printed? python a = [1, 2, 3] b = a 2 b[0] = 9 print(a, b)
- What is printed? python s = 'xxxy' print(s.rstrip('y'), s.strip('x'), repr(s.lstrip('xy')))
- What is printed? python print('abc' < 'abcd', 'Z' < 'a', '10' < '9')