[Tutor] same ol s

Lloyd Kvam pythonTutor at venix.com
Thu Aug 12 02:16:53 CEST 2004


Danny already told you that we try to limit our help to references on
homework assignments.

On Wed, 2004-08-11 at 19:39, jason hochstein wrote:
> The median is the middle number in your list,  if the numbers are sorted in
> ascending order. 
If you look up the list methods, you will find how to sort a list.

THis is the general index to Python documentation:
http://docs.python.org/lib/genindex.html

In the L section, look for:
	list type, operations on


> If it is an even numbered list, 

An earlier response pointed out that you can use the modulus operator to
test for even or odd.  I'll repeat that here,

number % 2 == 0	# true when number is even
	
> the median would be half
Half of a number, is the number divided by two.  Look up the divmod
function if you need help with division in python.  divmod can also help
with detecting even versus odd.

> way between the 2 middle numbers. (1,2,3,4,5,6,7,8,9) 5 is the median.
Do you know how to reference an element in a list?  From your example
above,
list = [1,2,3,4,5,6,7,8,9]
list[0] # will reference the first element, the 1
list[1] # will reference the second element, the 2
and so on.  The Python tutorial (and Alan Gauld's) tutorial cover this.

That should help in picking out the middle number.

> 
> The mode is the number making the most common appearance. (1,2,3,3,3,4,5) 3
> is the mode.

You received some detailed help for computing the mode earlier.

> 
> ----- Original Message ----- 
> From: "Alan Gauld" <alan.gauld at blueyonder.co.uk>
> To: "jason hochstein" <bigapple631 at optonline.net>; <tutor at python.org>
> Sent: Wednesday, August 11, 2004 7:31 PM
> Subject: Re: [Tutor] same ol s
> 
> 
> >
> > > I am still having problems getting the median and mode
> >
> > Groan, I hate statistics...
> > Remind me again, what are the definitions of median and mode?
> >
> > Alan G.
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582



More information about the Tutor mailing list