NOOB coding help....

James Stroud jstroud at mbi.ucla.edu
Mon Feb 21 23:20:35 EST 2005


Could you phrase this in the form of a question, like Jeopardy?


On Monday 21 February 2005 08:08 pm, Igorati wrote:
> Ok, this is what I have so far:
>
> #This program will ask for a user to imput numbers. The numbers will then
> be calculated
> #to find the statistical mean, mode, and median. Finallly the user will be
> asked
> #if he would like to print out the answers.
> list = [ ]
> a = 1
> print 'Enter numbers to add to the list. (Enter 0 to quit.)'
> while a != 0 :
>     a = input('Number? ')
>     list.append(a)
> zero = list.index(0)
> del list[zero]
> list.sort()
>
> variableMean = lambda x:sum(x)/len(x)
> variableMedian =  lambda x: x.sort() or x[len(x)//2]
> variableMode = lambda x: max([(x.count(y),y) for y in x])[1]
> s = variableMean(list)
> y = variableMedian(list)
> t = variableMode (list)
>
> x = (s,y,t)
> inp = open ("Wade_StoddardSLP3-2.py", "r")
> outp = open ("avg.py", "w")
> f = ("avg.py")
> for x in inp:
>     outp.write(x)
> import pickle
> pickle.dump(x, f)
>
>
> print 'Thank you! Would you like to see the results after calculating'
> print 'The mode, median, and mean? (Please enter Yes or No)'
> raw_input('Please enter Yes or No:')
> if raw_input == Yes:
>
>     f = open("avg.py","r")
>     avg.py = f.read()
>     print 'The Mean average is:', mean
>     print 'The Median is:', meadian
>     print 'The Mode is:', mode
>
> I am attempting to make it so that I can save the mean, meadian, and mode
> and then if the user wants the data to give it to him. Thank you for any
> assistance you can provide!
>
> Wade

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095



More information about the Python-list mailing list