- 5

Addition of two numbers

1st Sep 2018, 4:29 PM
Ramyajayanthi
Ramyajayanthi - avatar
9 odpowiedzi
+ 3
Python: a = 40 b = 2 print(str(a + b)) outpet: 42
1st Sep 2018, 4:45 PM
Potato Squad
Potato Squad - avatar
+ 3
Potato Squad it seems I was wrong. Thank you for correcting me
1st Sep 2018, 7:28 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 2
Potato Squad that example is 402 because it's a string. It would be better like this. a = 40 b = 2 print(int(a + b)) outpet: 42
1st Sep 2018, 5:04 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 2
Ramyajayanthi (chaining is addition of string with some type). It will work without the str either in this case but I send it just in case you will think python chaining it's like java or another language (string + int = string) in python you need to use str function in chaining or use string formatting.
1st Sep 2018, 5:17 PM
Potato Squad
Potato Squad - avatar
+ 1
Really?
1st Sep 2018, 4:42 PM
KrOW
KrOW - avatar
+ 1
Lol
1st Sep 2018, 4:45 PM
Potato Squad
Potato Squad - avatar
+ 1
Better: addition of two strings
1st Sep 2018, 5:41 PM
BraveHornet
BraveHornet - avatar
1st Sep 2018, 5:56 PM
Potato Squad
Potato Squad - avatar