Common Computer Science References
At the end of this lesson, you will be able to:
understand what a variable is and how to use one
create an application that accepts input and saves it into a variable
understand what a top-down design is and how to create one
review basic output and formatting
read Top-Down Design, from textbook Computer Based Problem Solving
and read Top Down Design in Programming, from textbook Computer Based Problem Solving
go over what a Top-Down Design is
we use square line connectors and rectangular boxes
arrows always point down
normally left black & white
go over how to create one using draw.io
the new, easier way is to use VSCode and the Draw.io extension, right from GitHub!
just use the Codespace externsion
or just type "period" (.), from any GitHub Repo to get into VSCode web version
to get your Top-Down Design 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!
read Variables, from textbook Computer Based Problem Solving
go over what a variable is
different naming conventions:
see "Different Naming Conventions" below: ↓
we will always use this rule, for Python:
lowercase with words separated by underscores as necessary to improve readability
ex: area_of_rectangle, time_of_day, number_of_students
this "=" IS NOT an equal sign, it is an assignment statement
go over how to get input from a user
we need the "int" to convert the user input which is of "type" string to integer, since we can not do math with strings!
python:
# just start using a variable right away in Python
length = int(input("Enter length of the rectangle (mm): "))
C
// declare the variable first in C
int length;
...
// then you can use it!
printf("Enter length of the rectangle (mm): ");
scanf("%d", &length);
NOTE: that we have used &length inside scanf(). It is because &length gets the address of length, and the value entered by the user is stored in that address.
nill
create a program that calculates the area and perimeter of a rectangle with dimensions entered by user and show the results to 2 decimal places (see terminal output below: ↓)
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
then write the code and check to ensure your answers are correct!
create the same above program in C
we will always use this rule, for C:
lowercase to start, then uppercase, with words NOT separated to improve readability
ex: areaOfRectangle, timeOfDay, numberOfStudents
at the moment we will use scanf to get input
I know this is a really bad idea, but we do not have enough skills yet to do it the correct way!
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.