[Tutor] Python

Steven D'Aprano steve at pearwood.info
Fri Oct 12 06:51:32 EDT 2018


On Thu, Oct 11, 2018 at 08:41:08PM -0500, Tyler Travis via Tutor wrote:

> I fully understand the concept of what I am trying to do 

I'm very glad that at least one of us understands what you are trying to 
do, but I have no clue what it is.


> and I know 
> that you can type out the algorithms to find mean, median, and mode 
> but I used a shortcut by import the statistics function. Which yields 
> the same results 

The same results as what?


> and the program passes with a 100% in the grading software 

Great!


> However, it does not print the expected output, but rather 
> some random sequence of characters and numbers. I do not understand 
> why. Do you know why?

Your computer is cursed? Your cat walked over the keyboard?

I don't understand how your two statements can be reconciled. You say 
that the program pass the grading software. Surely that means it must 
print the expected output. (How else will the grading software know it 
gives the correct results?)

But then you say it prints gibberish. So I imagine you are doing this:

print(mean([1, 2, 8, 9])  # expected output is "5"

# output actually printed is "dz!gwd{7p3^)n3d%hw8"
# and the grading software says "Correct, full marks!"

which makes no sense to me.

By the way, I'm the author of the statistics module, so I'm very glad to 
hear that you are using it, but if the point of the exercise is to write 
your own (simple?) versions of mean, median and mode, isn't it cheating 
to use the pre-written ones?



-- 
Steve


More information about the Tutor mailing list