On Wed, Jan 06, 2016 at 07:04:24PM +0000, Alan Gauld wrote: > On 06/01/16 18:23, yehudak . wrote: > > My grandson Guy (8th grader) is learning Python at school. That's what made > > me teach myself Python programming as well. > > Yesterday he asked my help in his homework: > > > > Write a FOR-loop that prints all numbers up to 1000000 > > And the question is?
I don't think that Yehudak had a question, I think he is just sharing his experiences. (I think Yehudak is a male name, apologies in advance if I got that wrong.) > Python has a for loop and a print function. > It can easily handle numbers up to 1000000. > You probably need to look at the range() function too. > > If you are having difficulty with any of those concepts > let us know and ideally show us the code that fails. I'm guessing that Yehudak is griping about how slow it is and how much pointless output it generates. I agree: on my computer, just looping from 1 to a million takes 0.2 seconds, but printing out the numbers not only generates a million lines of output, but takes 100 times longer: 20 seconds. -- Steve _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
