- 1

May someone please explain this code for me?

x = 10 y = x + 6 y = int(str(y) + "4") print (y)

1st Feb 2021, 2:00 PM
little sparky
little sparky - avatar
2 Respuestas
+ 5
what is require ? Also use language name in tag . You can solve the problem yourself by just a little bit googling for right thing . str converts number to string i.e. "16" and when two strings are added they result in concatenation i.e. "16"+"4"="164" and int converts it back to number 164.
1st Feb 2021, 2:07 PM
Abhay
Abhay - avatar
+ 5
I am considering it's a python language so in python str method will convert number to string so here x = 10 y = x + 6 = 10 + 6 = 16 now here str(y) will convert 16 to string so as you know that when you add two or more string then it concatenate each other so here str(y) + "4" = 164 now int method will convert this string 164 to integer
1st Feb 2021, 2:31 PM
A͢J
A͢J - avatar