i have created quiz contains 10 maths questions. quiz outputs whether or not answer correct. coding correctly stores scores in simple notepad document. store sorted 3 different classes. stuck sorting score in alphabetical,numerical , average order, highest lowest. if give me coding sort scores in alphabetical, numerical , average order, appreciated.
sorted python built-in function, can use out of box.
the first example sorting alphabetical, need give sort parameter tells sorted need sort alphabetical.
the second example sorting number default sort of sorted means don't need put parameter sorted.
print sorted("this test 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, didn't quite understood need, can find average easily
import numpy = [3,5,7] numpy.mean(a) '5.0'
Comments
Post a Comment