osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Code for addition


On Saturday, August 5, 2017 at 6:55:09 AM UTC+5:30, Steve D'Aprano wrote:
> On Sat, 5 Aug 2017 12:43 pm, Ode Idoko wrote:
> 
> > Can anyone help with the python code that can add 101, 102, 103...2033 please?
> 
> 
> Sounds like homework. Here are some hints for you to play around with and see if
> you can get the right answer:
> 
> 
> sum([101, 102, 103])
> 
> range(101, 104)
> 
> sum(range(1, 4))
> 
> 
> What does sum() do?
> 
> What does range() do?
> 
> Can you put them together to get the answer you need?
> 

Or study math-history? Gauss? early years
https://brilliant.org/wiki/gauss-the-prince-of-mathematics/