+ 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 Respostas
+ 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)