Here I'm posting my solutions to the Practice Project for the
COMP10001 Foundation of Computing course in the University of Melbourne in Semester 2, 2016.
The solution below is just my solution. IT IS NOT:
- A sample answer from any lecturer, tutor, or any teaching staff.
- A marking scheme used for any of the actual assessments
- A perfect solution for anyone to take as a template for your project
- A reason for you to give up on trying your practice project
I advice you to try on your own first before you read this solution.
All the following solutions has been put to test with the Grok System, but it might NOT be fulfilling the code quality requirement of the marking scheme. (Although I think it should, XP)
Again, the license:
Copyright (c) 2016 Eana Hufwe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- All source files in this solution follows PEP8 (Python Enhancement Proposals 8: Style Guide for Python Code, the de facto style guide for all Python users) as far as possible.
docstrings follows Google's Python Style Guide as far as possible.
- All file-level
docstrings repeats the question in Markdown, extended with inline LaTeX support.
- Shellbang, for direct refer to the script in most shell.
- Encoding declairation, although not necessary in this context.
docstring, repeats the question.
- Import libraries, if necessary.
- File meta-information declaration, including author, copyright, license, version, and contact.
- Define functions
docstring, state briefly what the function does, examples, argument(s), and return value(s).
- Code, Commenting on each necessary step
What to notice with PEP8?
- Concise Style Guide (LMS Link, requires accessibility, login before visit)
- Always distribute your code in UTF-8
- Where to put whitespaces
- Where to put blank lines
- Where and how to indent
- Anyway just read the whole thing if you have time
Again, this is not a guide or something. Just sharing my solution. Please don't take it as a guidebook. If you really want one, please consult PEP8.