+ 1

Why value of "x" will be 70 ?

>>> x="7" >>> x=x+"0" >>> print(x) 70

11th Aug 2019, 12:47 AM
Twiddle
Twiddle - avatar
2 Respuestas
+ 8
Literals within quotes are string literals. The addition operator performs concatenation on strings. In this case, "7" is concatenated with "0" and assigned to x. Printing x will result in "70" being printed.
11th Aug 2019, 12:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
Here x = "7" 7 is string in this syntax x=x+"0" Here x is string which value is 7 and 0 also string. When we add the string 7 and 0 Output will be 70.
11th Aug 2019, 5:30 AM
Sujan Sharma
Sujan Sharma - avatar