[Tutor] Newbie question re. Functions

Jon Moore jonathan.r.moore at gmail.com
Tue Jan 31 13:10:54 CET 2006


I guess I am not going mad then!

I will skip this exercise and move on.

Thanks

Jon

On 31/01/06, Alan Gauld <alan.gauld at freenet.co.uk> wrote:
>
> Hi Jon,
>
> > Improve the function ask_number() so that the function can be called
> with
> > a
> > step value. Make the default value of step 1.
>
> If its any consolation that doesn't really mean much to me either.
> I understand the concept of step value - range() takes one for
> example, check the docs.
>
> But how a step value would be used in this kind of user-input scenario
> I have no idea!
>
> def ask_number(question, low, high):
>     """Ask for a number within the range"""
>     response = None
>     while response not in range(low, high):
>         response =  int(raw_input(question))
>     return response
>
> The only possibility I can think of is that the step value is used to
> narrow the acceptable range each time round the loop. But given
> we don't necessarily tell the user what the range is that would be
> weird. We'd need to modify question as we go or something.
>
> On the assumption you aren't being marked on this I'd just
> make up your own mind what it should do and do it! :-)
>
> ...and treat it as a good example of a bad statement of
> requirements!
>
> Alan G
>
>


--
Best Regards

Jon Moore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060131/2b1b5c8d/attachment.html 


More information about the Tutor mailing list