Re: [Edu-sig] explaining functions [Possibly OT]

I haven't run into 'don't understand what a function is' but I have run into 'don't understand why you would want to use one'. My youngish students would rather just paste the formula that is in the function again, and again. So I gave them a problem where they calculated the cost of a list of somethings with a tax rate of 5%. The pasters were more or less as fast as the function users. Then I said 'ok, now the government has lowered taxes. They are now 4%'. Suddenly the pasters saw that the function users had a much easier time of it. And the climax was when I made them fix _each others_ code to make it produce the correct results. I was called 'mean' for that. :-) Laura

Laura Creighton schrieb: This examples shows beautifully that there are different concepts of "function", which also shows up in Python: some are called to return a result - this *should* be independent of global circumstances (variables). (Like mathematical functions mentioned in Nicholas' posting.) The others are functions that *do* something, for instance draw a line (like forward from the turtle graphics module). What forward(50) produces is by no means independent of the state of the machine. (And it returns None!) So these are called merely because of their side-effects. And (regrettably?) there are many functions which do both: produce side-effects and return values (in the real world (especially of students)).
And the climax was when I made them fix _each others_ code to make it produce the correct results. I was called 'mean' for that. :-)
By all means, what does 'mean' mean in this context? Gregor
Laura
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
participants (2)
-
Gregor Lingl
-
Laura Creighton