Temp | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Temp

How temp=7 temp+=2 hives the output 72

29th Dec 2017, 6:43 AM
Rishav kumar
Rishav kumar - avatar
2 Respostas
+ 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.
29th Dec 2017, 7:00 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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'
29th Dec 2017, 9:03 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar