Re: [Tutor] Step Value

2011-06-17 Thread Steven D'Aprano
Vincent Balmori wrote: Here is my updated code. As simple as this may be, I am a little lost again. I appreciate the help and explanations to try to push me to get this on my own, but at this point (especially after one week) this is when me being given the answer with an explanation will help me

Re: [Tutor] Step Value

2011-06-17 Thread ALAN GAULD
>> def ask_number(question, low, high, step = 1): >> """Ask for a number within a range.""" >> response = None >> while response not in range(low, high, step): >> response = int(input(question)) >> return response > > With the only comment being that you don't really need the > resp

Re: [Tutor] Step Value

2011-06-17 Thread Andre Engels
On Fri, Jun 17, 2011 at 11:03 PM, Alan Gauld wrote: > > "Vincent Balmori" wrote > >> Here is my updated code. As simple as this may be, I am a little lost >> again. > > I'm not sure why you are lost because that's pretty much it. > >> ... at this point (especially after one week) this is when me

Re: [Tutor] Step Value

2011-06-17 Thread Alan Gauld
"Vincent Balmori" wrote Here is my updated code. As simple as this may be, I am a little lost again. I'm not sure why you are lost because that's pretty much it. ... at this point (especially after one week) this is when me being given the answer with an explanation will help me much more,

Re: [Tutor] Step Value

2011-06-17 Thread Vincent Balmori
gain at how Steven defined his function. > What is different about his definition of n and your definition of > step? > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > ______

Re: [Tutor] Step Value

2011-06-17 Thread Alan Gauld
"Vincent Balmori" wrote "def spam(n=3): """Return n slices of yummy spam.""" return "spam "*n This is my new code for a default step value based on your feedback Steve: def ask_number(question, low, high, step): """Ask for a number within a range.""" response = None if step == N

Re: [Tutor] Step Value

2011-06-16 Thread Válas Péter
Please try to reply to the previous letters instead of starting a new thread each time. Thank you! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Step Value

2011-06-16 Thread Vincent Balmori
"def spam(n=3):     """Return n slices of yummy spam."""     return "spam "*n And here it is in use: >>> spam(4) 'spam spam spam spam ' >>> spam()  # just use the default 'spam spam spam ' Can you see what I did to set the default value for n? Read the function definition line "def spam... " ca

Re: [Tutor] Step Value

2011-06-16 Thread Steven D'Aprano
Vincent Balmori wrote: Okay, I think I understand it better for the quesiton: "Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1." Here is the improved function and the human_move function that calls it later on. The thing

[Tutor] Step Value

2011-06-16 Thread Vincent Balmori
"From Steven D'Aprono: * change the ask_number function to accept a fourth argument; * make it optional rather than required; * give it a sensible default value; * within the function, that value must then be passed to range " Okay, I think I understand it better for the quesiton: "Improve the fun

Re: [Tutor] step value

2011-06-15 Thread Steven D'Aprano
Vincent Balmori wrote: The question to that code I am trying to solve is "Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1." You need to be able to tell ask_number what step function you want to use. So it isn't enou

Re: [Tutor] Step Value

2011-06-15 Thread Alan Gauld
"Vincent Balmori" wrote I am still working on that one question in the absolute beginners with the the ask_number function and step value. Honestly, I still have no idea what to do. Take it stage by stage. Define the function so that it takes a step parameter with a default value of 1. Don;

Re: [Tutor] step value

2011-06-15 Thread James Reynolds
I am copying and pasting your code here from the previous email: def ask_number(question, low, high): > """Ask for a number within a range.""" > response = None > if response in range(low, high, 1): > return response > while response not in range(low, high): > respon

[Tutor] step value

2011-06-15 Thread Vincent Balmori
The question to that code I am trying to solve is "Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1." ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] Step Value

2011-06-15 Thread James Reynolds
Without looking at your code, What is it that you know that's wrong about it? Are you getting a return value which you know is incorrect, is the program throwing error and you aren't sure why? or do you just suspect it is wrong but you aren't sure? When posing a question, it's helpful to know the

[Tutor] Step Value

2011-06-15 Thread Vincent Balmori
I am still working on that one question in the absolute beginners with the the ask_number function and step value. Honestly, I still have no idea what to do. This is one of my many attempts, but I know that it's wrong. def ask_number(question, low, high): """Ask for a number within a range."

Re: [Tutor] step value

2011-06-13 Thread Steven D'Aprano
Vincent Balmori wrote: I am stuck on a question for Absolute Beginner's. I googled this and there have been others who have not understood the question and I am also not clear on the question he is asking. This function is a part of a tic tac toe program."Improve the function ask_number() so th

[Tutor] step value

2011-06-13 Thread Vincent Balmori
I am stuck on a question for Absolute Beginner's. I googled this and there have been others who have not understood the question and I am also not clear on the question he is asking. This function is a part of a tic tac toe program."Improve the function ask_number() so that the function can be