Common Computer Science References
At the end of this lesson, you will be able to:
understand what a constant is and how to use one
understand what a flowchart is and how to create one
review variables
read Flowcharts, from textbook Computer Based Problem Solving
read Constants, from textbook Computer Based Problem Solving
go over what a Flowchart is
we use square line connectors
different shapes have different meanings
arrows always point down
normally left black & white
go over how to create one using draw.io
yes, same extension as for Top-Down Designs
once again, to get your Flowchart into your Google Doc ALWAYS export it as a PNG file
the reason is that the resolution of the diagram is kept and even if you need to shrink it to fit nicely on the page, I can zoom in and still see all the text
File, Export As, PNG...
then insert it into your Google Doc
Insert, Image
ensure you then center, size and crop the image appropriately so it fits nicely on one (1) page
NEVER take a screenshot from Draw.io and paste that in!
go over what a constant is
we will always use this rule:
uppercase with words separated by underscores as necessary to improve readability
also, constants will always be created in a separate module
go over how to create a module, it is just a separate python file
ex: MONTHS_IN_YEAR, SECONDS_IN_HOURS, HST
note: in python even when you declare a constant, someone could still change it; this is not true in all languages; in C and swift for example if you declare a constant it can never be changed
to get around this we normally create a new python file (usually called constants) and place our constants in there and then "import" that file
see Mars program (see source code below: ↓)
ensure you click on "Show Files" to see the mars.py file, if you can not see the file explorer
once there, ensure you click on "Files" to see the constants.py file as well
create a program that calculates the circumference of a circle using τ (tau), with radius entered by user and having 3 decimal places (see terminal below: ↓)
C = τr, τ ~= 6.28
dimensions entered by user
come up with three (3) test case, BEFORE YOU WRITE THE CODE to ensure you know what the answer should be BEFORE you start coding
note, you can not use my test cases!
then check to ensure your answers are correct!
you will have to create a constants.py file to hold the value of tau
remember, TAU in your constants file should be in all CAPS
create the same above program in C
constants in C can be done 2 different ways:
we will just use const, so that it is not global and can be type checked!
constant example in C:
note: constants in C are NOT declared in a separate file, they are declared above variables
const int LENGTH = 10;
Tau versus pi
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.
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.