C-16-Q134mediumsingle_mcq
Why must we convert input to int before doing arithmetic on numbers entered by the user?
Why must we convert input to int before doing arithmetic on numbers entered by the user?
- aBecause input() returns int by default and we must keep it
- bBecause input() returns a string, and arithmetic on strings differs from arithmetic on integers
- cBecause Python disallows arithmetic on integers
- dThere is no need to convert
ব্যাখ্যা
input() always returns a string, so without conversion arithmetic operators behave differently — for example + concatenates text instead of adding numbers. Converting with int() ensures the values are treated as numbers so calculations give correct results.