Truthy values go through most C type languages. Python included. bool(2) is True
>>> True + True
2
>>> True * 13 + (1 - False) * 17
30(The same happens in R, for what it's worth. as.integer(TRUE) is one and as.integer(FALSE) is zero and the operations you wrote work just he same.)