What happens when int(“3.5”) is evaluated in Python?
Correct answer A. A ValueError is raised
Explanation
int() can parse a string only if it represents an integer literal, so the decimal point makes "3.5" invalid and a ValueError is raised. int(3.5) with a float does work and truncates to 3. To convert the string, use int(float("3.5")).
Answer checked How we write and check questions
Discussion