0
A very basic question
In this code: Print(âsolve this math problemâ) X=int(input(âcalculate 99-76= â)) If (x==23) Print(âcorrectâ) Else: Print(âincorrectâ) Type conversion is necessary else the code evaluates to âincorrectâ But in code: S=input(â: â) If s==q: Break No type conversion is necessary. Why?
3 RĂ©ponses
+ 10
What is q? Did you mean "q"?
I think the default for input is string, that is why you need to convert it (correct me if I am wrong).
+ 3
The second code is not complete, is it?
If q (which could for example mean question) was a string, then there would be no conversion necessary, because s also is a string. Input always comes as string.
+ 1
yes the second code is not complete. i just wanted to know the difference for type conversion.
i ran this program:
s=input()
print(type(s))
and no matter if the input is an int, float or string, the output is always âstrâ.
thankyou for the help