Common Computer Science References
At the end of this lesson, you will be able to:
write a program that actually does something useful, well sort of
review proper style
the entire point of creating electronic computers was to automate doing math, so lets get the computer to do simple math for us
demo of python doing basic math (see source code below: ↓)
add
subtract
multiply
divide
exponent
in Python and C "^" actually means Bitwise XOR!
x**y means exponent in python
pow(x,y) in C
how to format expressions along with text in a print statement
and this video
see: C String Formatting
go over test cases and why they are needed
see: Test Cases
see: What can happen when proper testing is not done!
what it means to be an Engineer in Canada; and their strange traditions!
create a program that calculates the area and perimeter of a rectangle with dimensions 5 cm by 3 cm, with proper style and shows 3 decimal places (see terminal below: ↓)
come up with just one (1) test case for area and perimeter, BEFORE YOU WRITE THE CODE to ensure you know what the answer should be BEFORE you start coding
hint: the test case is:
a = l × w or a = 5 × 3
p = 2(l + w) or p = 2(5 + 3)
since there is only 1 correct answer each!
push the changes back to GitHub
NOTE: the SI standard for using units with numbers!
Area is 15 cm².
NOTE: the space after the number and the units and using superscripts for squared and NOT "^"!
to get the squared, google "unicode squared"
read Introduction, Computer Based Problem Solving
the entire chapter
create the area and perimeter program in C, with proper style
you only have to do test cases once, not for each language
you better get the same result each time!
in C you might need to do the following while building with the math library:
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.