Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
int("3" + "4") isn't necessarily the same as int("3") + int("4"), but rather the same as the following code (but without the extra variable): x = "3" + "4" # x is now "34" int(x) # Converts x to a string With the int function, it will essentially evaluate the expression within the brackets before continuing with the type-conversion, which is why the output is 34 rather than 7
23rd Jul 2019, 6:29 AM
Faisal
Faisal - avatar
+ 2
Because the plus operator has three implementation. Arithmetic addition for integer, arithmetic addition for floating number and concantention for string. When 3 is enclosed with quotation mark, it is a string, so the plus operator is string concantention here, just like "a" + "b" = "c"
23rd Jul 2019, 8:10 AM
Gordon
Gordon - avatar
+ 2
Int("3" +"4") will never be equal to 7. Because 3 and 4 are enclosed in a quote, which makes them a type string. Int (3+4) != int("3" + "4"). The +sign just join the two strings together. Like x = ( "james" + "bond" ) So, x = jamesbond
23rd Jul 2019, 10:20 AM
ADEBISI MAYOWA
+ 1
In short, You are using quotations so you're not adding, you're putting together. If: "A"+"b"= Ab Then "3"+"4"+= 34
30th Nov 2019, 8:37 PM
Stivo Gutierrez
Stivo Gutierrez - avatar
0
Because ("3" + "4")-strings But (3 + 4)-not strings
31st Jan 2020, 6:31 PM
Rustiktam
Rustiktam - avatar