On 2019-01-14 23:29, caig...@gmail.com wrote:
So I was given this question to be solved in Python 3 : Pick any 3 random 
ascending numbers and write out a loop function that prints out all 3 numbers. 
This was the code and solution presented to me. Can anyone understand it and 
explain it to me please ? I have looked at it but cannot see how it was derived 
and why the correct solution was printed. Thanks alot !

# any 3 ascending numbers , counter must start at 0.
# 400 467 851
i = 0
x = 400
while x < 852:
print(x)
if i > 0:
x = x + ((i + 4) * 67) + (i * 49)
else:
x = x + 67
i = i + 1


      This sounds like a homework problem for a class.  I don't know how this list treats such questions, but I suspect answering such questions may be discouraged.


      Hint:  Read the documentation on "while" and then trace the iterations.


      Spencer



--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to