On Wed, Jul 27, 2011 at 9:11 PM, Thomas C. Hicks para...@pobox.com wrote:
On Wed, 27 Jul 2011 20:16:31 -0400
Alexander Quest alexxqu...@gmail.com wrote:
x=range(1,50)
mid=x[len(x)/2]
You would have to make sure there is a way to work around decimal points in
the division. Also, I would try
Does anyone know how to assign a certain numerical range to a variable, and
then choose the number that is the middle of that range? For example, I want
to assign the variable X a range between 1 and 50, and then I want to have
the middle of that range (25) return with some command when I call it
Alexander Quest wrote:
Does anyone know how to assign a certain numerical range to a variable, and
then choose the number that is the middle of that range? For example, I want
to assign the variable X a range between 1 and 50, and then I want to have
the middle of that range (25) return with
Thanks Steven- I'll try that out.
-Alex
On Wed, Jul 27, 2011 at 5:40 PM, Steven D'Aprano st...@pearwood.infowrote:
Alexander Quest wrote:
Does anyone know how to assign a certain numerical range to a variable,
and
then choose the number that is the middle of that range? For example, I
On Wed, 27 Jul 2011 20:16:31 -0400
Alexander Quest alexxqu...@gmail.com wrote:
Does anyone know how to assign a certain numerical range to a
variable, and then choose the number that is the middle of that
range? For example, I want to assign the variable X a range between
1 and 50, and then I
You could start with an anonymous function using the lambda operator, such as:
mid_range = lambda x: x[len(x) // 2]
Note: If you use len(x) / 2 in python 3.x you will get a TypeError because the
division operator / returns a float.
Thanks for that Donald!
-Alex
On Wed, Jul 27, 2011 at 8:16 PM, Donald Wilson donald...@me.com wrote:
You could start with an anonymous function using the lambda operator, such
as:
mid_range = lambda x: x[len(x) // 2]
Note: If