0

Can someone explain this to me?

a = "7" a = a + "0" b = int(a) + 10 print(int(a)+b)

7th Sep 2020, 6:15 PM
Dodge Bludau
Dodge Bludau - avatar
3 Answers
+ 6
a=a+"10" a="7"+"10" ,concatenates two strings a="70" b=int(a)+10 b=70+10 #int(a) converts string to int b=80 print(int(a)+b) a is still holding a string value ,i.e. "70" ,int again converts string to int and finally you get, 70+80=>150
7th Sep 2020, 6:20 PM
Abhay
Abhay - avatar
+ 5
Use the tag your programming language you want help.
7th Sep 2020, 6:17 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 3
a = "7" // string "7" a = a + "0" // string "70" - addition of strings b = int(a) + 10 // int 80 - a is converted to int print(int(a) + b) // output 150 - addition of 2 intagers I'm not sure what language this is... Seems like weird js/py
7th Sep 2020, 6:20 PM
nicolas turek
nicolas turek - avatar