Common Computer Science References
At the end of this lesson, you will be able to:
re-create your first program, with correct style
review Git and GitHub
when you create programs, you are NOT creating them just for the computer
you have 2 audiences:
computer
every other developer that has to look at your code, including you!
your program source files need to be machine and human friendly
go over style guide for Python:
points to remember:
use 4 spaces per indentation level
spaces are the preferred indentation method
limit all lines to a maximum of 79 characters
comments should be complete sentences. The first word should be capitalized ...
# This is a comment.
python Docstrings need for modules, function, ...
"""
Created by: Mr. Coxall
Created on: Sept 2020
This is the "Hello, World!" module, with proper style
"""
follow Python standard naming styles
function names should be lowercase, with words separated by underscores as necessary to improve readability
variable names follow the same convention as function names
ALWAYS use a proper name for a variable, NEVER something like "i"
ex: time_of_day
constants are all CAPS: MAX_OVERFLOW
always include a shebang (yes this is not a mistake):
#!/usr/bin/env python3
it will most likely not make much sense now, but it will eventually!
after the shebang, ALWAYS include a Docstring with your name, program creation date and at least one (1) sentence explaining what the *.py file does
this is so everyone knows who created it, when and for what reason
always use: if __name__ == "__main__":
do demo of using black
use it on all your python code to ensure you are following the rules
black --check --diff ./*.py
look for something like:
All done! ✨ 🍰 ✨
2 files would be left unchanged.
now look at the "Mr Coxall's Super Linter" badge
it MUST be green from now on
also look at the "GitHub Actions" to see if you have any errors, and then fix them!
re-create your "Hello, World!" program, with proper style (see example below: ↓)
check to ensure you are following all the rule, use black (see example below: ↓)
follow any hints it might give you and correct your style
push the changes back to GitHub
when done, ensure your GitHub "Badge" in your README.md file is green
create a second program (HelloWorld.c) with proper style:
(see image below: ↓)
we will use Google's C++ Style Guide
to check the style
use: cpplint ./*.c
output should be like: Done processing ./helloWorld.c
have it committed back to GitHub
confirm your README.md badge is still green
Why we have is weird stuff in our python programs
it might not make much sense now; by the end of the course it will
NOTE: You can turn on "Closed Captions" to see a printout of what is being said by selecting the "CC" button.
You can also have it translate the closed captions by going to "Settings, Subtitles/CC, Auto-translate" and then pick your prefered language.