Exam-style question
Try this first
In Python 3, which expression converts the string "42" into an integer?.
- A.str("42")
- B.float("42")
- C.int("42")
- D.chr("42")
Model answer
What a good answer should say
- int("42")
Explanation
Why this works
int converts a suitable string representation of a whole number into an integer. str performs conversion to a string, float produces a floating-point value, and chr requires a character code integer.
Common mistake
No common mistake is linked to this question yet.
