+ 2
Type conversion
Why isn’t it 7. I thought the explanation said print(int(“3”+”4”) would be 7?? Am I just hallucinating or what??
4 Respuestas
+ 9
int("3"+"4") = int("34") = 34
int("3")+int("4") = 3+4 = 7
+ 3
thanks heaps that makes sense now i was just a bit confused!!
+ 1
Calculations with parentheses from the innermost set outwards, like in maths!
0
here in the code print(int(“3”+”4”)
3 and 4 are converted to string due to being enclosed in double quote, and + operator is concatenating those string to 34.and again it is converted to integer type by using explicit type conversion of int(parameter/expression)
thus, if you are wanting to print 3+4=7
try just
print(3+7)