On Wed, Jul 27, 2011 at 9:11 PM, Thomas C. Hicks wrote:
> On Wed, 27 Jul 2011 20:16:31 -0400
> Alexander Quest 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 it in practice. (remember range(
Thanks for that Donald!
-Alex
On Wed, Jul 27, 2011 at 8:16 PM, Donald Wilson wrote:
> 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 l
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. Fl
On Wed, 27 Jul 2011 20:16:31 -0400
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 t
Thanks Steven- I'll try that out.
-Alex
On Wed, Jul 27, 2011 at 5:40 PM, Steven D'Aprano wrote:
> 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 as
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 so
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