-6

I have created a quiz that contains 10 maths questions. The quiz outputs whether or not the answer is correct. The coding also correctly stores the scores in a simple notepad document. The store is sorted into three different classes. Now I am stuck sorting the score in alphabetical,numerical and average order, from the highest to the lowest. If you could give me the coding to sort the scores in alphabetical, numerical and average order, it would be very much appreciated.

Peter
  • 1
  • 1
  • Add you code which shows your attempt and it will be easy to show you where you went wrong – Padraic Cunningham Jul 16 '15 at 11:41
  • I've tried many different codings but none seem to work – Peter Jul 16 '15 at 11:45
  • if you are trying to sort string digit then it won't work, python sorts strings lexicographically so "2" would be considered greater than "1000000" but without seeing your input and expected output it is impossible to help you – Padraic Cunningham Jul 16 '15 at 11:51
  • We are all very tired of seeing low-quality questions related to this GCSE coursework exercise. *"If you could give me the coding"* - this is **not** a code-writing service, and note that just **asking others to write code for you is cheating**. Take the [tour] and read [ask]. – jonrsharpe Jul 16 '15 at 12:07
  • I'm voting to close this question as off-topic because this is neither a code-writing nor tutorial service – jonrsharpe Jul 16 '15 at 12:07

1 Answers1

1

sorted is a python built-in function, you can use it out of the box.

the first example is sorting alphabetical, you just need to give the sort another parameter that tells the sorted that he need to sort by alphabetical.

the second example is just sorting by number which is the default sort of sorted which means you don't need to put an extra parameter to the sorted.

print sorted("this is a test for alphabetical sort".split(), key=str.lower)
'['a', 'alphabetical', 'for', 'is', 'sort', 'test', 'this']'

print sorted([4,5,3,6,2,7]) # example of number sorting
'[2, 3, 4, 5, 6, 7]'

you mention average, i didn't quite understood what exactly that you need, but you can find average really easily

import numpy
a = [3,5,7]
numpy.mean(a)
'5.0'
omri_saadon
  • 10,193
  • 7
  • 33
  • 58