Question Detail

COS 102 lecture 4 Objective Question

Question

Which Python function converts a numeric value to an integer, truncating the decimal portion without rounding?
Options
A round(x)
B float(x)
C int(x)
Correct Answer
D abs(x)
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 43, in the 'Numeric Operations' table, states that 'int(x)' 'Converts the numeric value of x to an int. The decimal portion is truncated, not rounded.'

Hint

Refer to the 'Numeric Operations' table on page 43 for conversion functions.

Question Info