What is the return value of trunc()?
a) int
b) bool
c) float
d) None
Explanation: Execute help(math.trunc) to get details.
What is the output of print 0.1 + 0.2 == 0.3?
a) True
b) False
c) Machine dependent
d) Error
Explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3.
Which of the following is not a complex number?
a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J
Explanation: l (or L) stands for long.
What is the type of inf?
a) Boolean
b) Integer
c) Float
d) Complex
Explanation: Infinity is a special case of floating point numbers. It can be obtained by float(‘inf’).
What does ~4 evaluate to?
a) -5
b) -4
c) -3
d) +3
Explanation: ~x is equivalent to -(x+1).
Which of the following is incorrect?
a) x = 30963
b) x = 0x4f5
c) x = 19023
d) x = 03964
Explanation: Numbers starting with a 0 are octal numbers but 9 isn’t allowed in octal numbers.