Question Detail

COS 102 lecture 4 Objective Question

Question

When using int(x) for integer conversion in Python, what happens to the decimal portion of the numeric value x?
Options
A It is rounded to the nearest whole number.
B It is truncated, not rounded.
Correct Answer
C It causes a type error if <code>x</code> is a float.
D It is converted to a string representation.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 43, under 'Numeric Operations', states for 'Integer Conversion (int(x))': 'The decimal portion is truncated, not rounded.'

Hint

Find the description of 'Integer Conversion' using int(x) in the 'Numeric Operations' table on page 43.

Question Info