
Learning outcomes
By the end of this chapter, you should be able to:- use
input()for user input - convert input into required data type
- take multiple values in one line
- print clean output using formatting
Basic input
input() always returns a string.
Numeric input with conversion
int()for integersfloat()for decimals
Multiple inputs in one line
Output formatting
f"..." formatting is clean and exam-safe.
Common mistakes
- forgetting type conversion after
input() - using
+between string and integer - expecting
input()to returnintautomatically
Exam-focused points
- default return type of
input()isstr - type conversion functions:
int(),float(),str() split()returns a list of strings
Practice questions
- Take length and breadth as input and print area.
- Take 3 marks and print total and average.
- Write program to input name, class, and roll number and print in one formatted line.
