Python Type Conversion and input() Quiz
- Questions: 15
- Easy
- Pass mark: 70%
Everything a user types into input() arrives as text, even when it looks like a number. Before a program can add stage masses, compare burn times or multiply a crew size, it has to convert that text with int() or float(), and sometimes turn numbers back into text with str(). This free quiz has 15 short questions on how Python converts between types and what happens when a program forgets to.
What the quiz covers
- What
input()returns, including when the user just presses Enter - Converting text with
int()andfloat(), and which text raises aValueError - Numbers kept as text: joining, comparing and counting digits
- What
int()does to a negative float, and which valuesbool()turns intoFalse - Checking input with
isdigit(), reading several numbers withsplit()and accepting a decimal comma
How it works
- 15 questions: 11 with one correct answer, 4 where you select every correct answer
- After each question you see the correct answer and a short explanation
- In questions with
input(), the answer is only whatprint()shows, not the prompt or what the user types - No time limit and no account needed
- Score 70% or more (11 of 15) to pass
You can try the conversions in runnable examples: type conversion, basic data types and dynamic typing. After this one, try the Python Data Types Quiz or the Python Variables Quiz.