+ 1
Temp
How temp=7 temp+=2 hives the output 72
2 ответов
+ 7
temp = '7'
temp += '2'
print temp
The above will output 72 because the values are strings and are being concatenated together, not added mathematically.
temp = 7
temp += 2
print temp
This will output 9 as 7 and 2 are now numbers and mathematical calculations can occur.
+ 2
7 and 2 are of type int, not string, so answer cannot be 72, only when '7' and '2' are used then you get '72'