Q.
fname = input("Enter your first name: ")
Enter your first name: Arnab
age = input("Enter your age: ")
Enter your age: 19
fname = input("Enter your first name: ")
Enter your first name: Arnab
age = input("Enter your age: ")
Enter your age: 19
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →The input() function in Python always returns a string, regardless of what the user types. So age holds the string "19", not the integer 19.
This is a code / query task — you are being asked to understand what the code does and what data type each variable holds after execution.
The Idea: input() Returns a String
The key concept here is that Python’s input() function reads everything from the keyboard as a string. Even if the user types digits like 19, Python treats it as the text "19" — you cannot do arithmetic on it directly.
When you write:
fname = input("Enter your first name: ")
and the user types Arnab, fname becomes the string "Arnab".
When you write:
age = input("Enter your age: ")
and the user types 19, age becomes the string "19" — not the integer 19.
A very common mistake is to assume age is an integer and try to use it in a calculation like age + 1. That would raise a TypeError because you cannot add an integer to a string. You must explicitly convert with int(age) if you need a number.
What the Code Actually Does
After execution:
fname→"Arnab"(astr) …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.