QuestenaPractice that shows what to review next
Question 12

Which outcome correctly compares `int("12")` with `int("12.0")`?

  1. Both calls return 12.
  2. Both calls raise ValueError.
  3. The first returns 12; the second raises ValueError.Correct answer
  4. The first returns 12; the second returns 12.0.

Explanation

The text `12` has the integer-literal form accepted by `int`, so it converts to 12. The decimal-point form is not accepted by this direct string conversion and raises `ValueError`; it is not silently rounded or truncated.

Continue with this test

Start practice
Question 12: Which outcome correctly compares `int("12")` with… · Python Fundamentals · Questena