Objective
Bring together everything you have learned in a well-structured program: small functions, a main function that receives the arguments and the if __name__ == "__main__" pattern. The arguments of each test are passed to the program as if you typed them in the terminal (they appear in the test cases).
Instructions
- Read from standard input lines with the format
name,grade(integer grade). - Options with
argparse:--min(integer, default 0, discards lower grades),--sort(nameorgrade, defaultname) and--format(textorcsv, defaulttext). - Sorting by
nameis alphabetical; bygrade, from highest to lowest grade (ties by name). Formattextshowsname: gradeand formatcsv,name,grade. - Write
main(argv=None)that returns the exit code and finish withsys.exit(main()). If no student is left after filtering, writeNo resultsto the standard error (file=sys.stderr) and return 1.
ana,8
luis,5
bea,9
bea: 9
ana: 8
luis: 5
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise