A student writes `age = input('Enter your age: ')` then `result = age + 1`. When they run the program and type 25, it crashes with a TypeError. What is the most likely cause?
Ainput() is not a valid Python function for reading user data
Bage holds the string '25', and you cannot add an integer to a string without explicit type conversion
CThe variable name age is reserved and cannot be used
Dprint() must be called before input() can work correctly
input() always returns a string — even when the user types digits. So age holds '25' (the two-character string), not the integer 25. Adding 1 to a string causes a TypeError. The fix is int(age) + 1 or age = int(input('Enter your age: ')). This is the most common I/O bug for beginners.
Question 2 Multiple Choice
A user runs a Python program and types the number 42 when prompted by input(). What is the data type of the value stored in the variable?
Aint — Python automatically converts digits to integers
Bfloat — all console values are stored as floating-point
Cstr — input() always returns a string regardless of what the user types
DThe type depends on what the user typed
input() unconditionally returns a str. The console works in text — it sends characters, not typed values. Python has no way to know whether '42' should be an integer, a float, or a phone number digit sequence. The programmer must decide by calling int(), float(), or another converter. This is by design, not a limitation.
Question 3 True / False
In Python, when a user types a number at the keyboard prompt, input() automatically returns an integer value ready for arithmetic.
TTrue
FFalse
Answer: False
input() always returns a str — the string of characters the user typed. No automatic conversion occurs. This is true in Python and most other languages: the keyboard/console layer deals in text only. To use the value in arithmetic, you must explicitly call int(), float(), or another conversion function.
Question 4 True / False
Including a clear, descriptive prompt with a trailing space — such as 'Enter your age: ' — is a best practice because it tells the user what to type and where the cursor is.
TTrue
FFalse
Answer: True
Good output design includes writing prompts that orient the user. A trailing space keeps the cursor visually separated from the prompt text, making the interface feel natural. A blank prompt (or no prompt) forces the user to guess what the program expects, which is a form of poor documentation. Clear prompts are part of making a program usable.
Question 5 Short Answer
Why does console input always arrive as a string, and what must a programmer do before using that input in arithmetic calculations?
Think about your answer, then reveal below.
Model answer: The console transmits text (characters), not typed values — it has no way to distinguish '42' as a number from '42' as part of a ZIP code or ID. The programmer must explicitly convert the string to the appropriate type using int(), float(), etc., before performing arithmetic.
Understanding this prevents the most common beginner I/O bug. Every interactive program that does math with user input needs a type conversion step. Forgetting it either causes a TypeError (Python) or silent wrong behavior like string concatenation ('5' + '3' = '53') instead of addition.