int ("2"+"3") | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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
įŽÆį°į°įŽÆ__į„įŽæį©āž°
įŽÆį°į°įŽÆ__į„įŽæį©āž° - 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