+ 5

int ("2"+"3")

why the answer is 23. I was thought that the answer is 5.

30th Jun 2019, 7:10 PM
May Thazin Nyein
May Thazin Nyein - avatar
7 Respostas
+ 7
the bracket or parenthesis operation is to be performed first i.e ("2"+"3") which is ("23") and still a string type...then int("23") will convert "23" to 23 which is now an integer data type
30th Jun 2019, 9:57 PM
Umar Idris
Umar Idris - avatar
+ 6
int('2') + int('3') = 5
30th Jun 2019, 8:28 PM
Anna
Anna - avatar
+ 5
"2” is a string and “3” is a string, so “2” + “3” = “23” because it’s not a number it’s a string. However, 2 is an integer and 3 is an integer, so 2 + 3 = 5
30th Jun 2019, 8:03 PM
Pete Cowling
Pete Cowling - avatar
+ 4
You first do "2"+"3"="23" and next int("23")=23
30th Jun 2019, 7:11 PM
Werg Serium
Werg Serium - avatar
+ 3
The operations inside the parenthesed are operated before calling the int constructor.
30th Jun 2019, 8:05 PM
Seb TheS
Seb TheS - avatar
+ 2
"2" and "3" are strings so they will concatenate and therefore become 23
30th Jun 2019, 9:12 PM
Moksh Haria
Moksh Haria - avatar
+ 2
Type ("2")>>>str #Cadena Type ("3")>>>str #Cadena Concatenación: "2"+"3"="23" type(int("23")) >>>int #Entero
30th Jun 2019, 10:37 PM
Denis Omar
Denis Omar - avatar