Computer Programming - Final Exam Review
high-level languages
"algebraic" in form; easier for writing complex programs; translated by interpreters or compilers
reserved words
"if", "for", "in"
functions
"print", "range"
data coverage testing (black box testing)
- ideal (not feasible): test all possible inputs (exhaustive testing) - actual (feasible): test all relevant categories of data - extreme cases - boundary cases (ex 50 lbs in bison project) - ordinary cases
byte
1 byte = 8 bits
one ASCII character =
1 byte, 8 bits
while-statement checklist
1. Choose a variable to control the loop 2. Initialize the variable *before* the loop 3. Use the variable in the Boolean expression on the while statement 4. Inside the loop, change the value of the variable such that the Boolean expression eventually becomes False
Theory-and-Test
1. Form a theory about what's wrong. 2. Use diagnostic output to test your theory before you change anything
3 types of errors
1. Syntax errors - mistakes in structure/form of the statements 2. Execution errors (run time errors) - an attempt to do an impossible operation 3. Logic error - incorrect algorithm such that it computes the wrong thing (computer program runs correctly but the user has made an error in logic)
function checklist
1. What does it do? 2. What goes in? 3. What comes out?
assignment process
1. evaluates expression 2. assigns value to variable
opening a file is about:
1. identifying the file we want to use 2. telling the operating system that we want to use this file for input ("r")
interface (how the main program and function connect)
1. name (of the function) 2. arguments (of the function) 3. return value
how to override double space when reading file and printing
1. use end = "", --> print(line, end="") 2. use strip to remove whitespace --> "print(line.strip())" 3. use print(line[:-1]) in charcter string apple\n, \n is position -1
unicode
8-32 bits; 1-4 bytes
ASCII
8-bits; 1 bytes
components of computer
Central Processing Unit (CPU) + main memory (RAM)
De Morgan's Law
Part 1. not(P and Q) = not P or not Q Part 2. not(P or Q) = not P and not Q
main memory (RAM) vs auxiliary storage
RAM is temporary while auxiliary storage is long-term
software development process
Requirements Design Implementation Testing Deployment Maintenance
control structures
a constant in a program that controls the order in which statements are performed
scalar
a data value that is only one value (as opposed to a data structure)
abstraction
a mental model that hides or removes complex details
interpreter
a program that simulates a computer whose machine language is a high-level language; (means machine language runs without translation and has no object code; interpreter executes code directly?)
compiler
a program that translates a high-level language into machine language
assembler
a program that translates assembly language into machine language
algorithm
a sequence of unambiguous instructions for solving a problem in a finite number of steps
programming language
a system of notation for writing algorithms in a form that a computer can process
errors
also called defects, bugs, faults
data structure
an aggregate of data that can be handled as a unit
execution errors (run time errors)
an attempt to do an impossible operation
Cobol
business applications; Grace Hopper
integration testing
combining all the units of the program and then testing
John von Neumann
developed concept of storing programs into memory
Fortran
first high-level programming language used outside lab for creating useful software products
logic error
incorrect algorithm such that it computes the wrong thing (computer program runs correctly but the user has made an error in logic)
Python uses an
interpreter
concatenate (verb)
join together end-to-end
3 aspects of learning
knowledge, understanding, ability
syntax errors
mistakes in structure/form of the statements
method
object-oriented function
C++
object-oriented programming; Bjarne Stroustrup
Java
platform-independent object-oriented programming; James Gosling
write a statement that prompts user to input a floating-point number into a variable called quizvar
quizvar = float(input("Enter value "))
scope
regions where the variable is known and available to use
%
remainder
iterative
repetition done with a loop
recursion
repetition through a function calling itself
3 fundamental control structures
sequence, selection, repetition
assembly language
similar to machine language, but symbolic rather than binary (translated from machine language by an assembler)
typing into a Python program is ______ _______
source code
function
subroutine, sub-program, routine, procedure
2 aspects of language
syntax (rules of structure and form) and semantics (meaning)
C
systems programming; Dennis Ritchie
return function
takes us back to main program and returns the result of that computation
Pascal
teaching fundamentals of computer science; Niklaus Wirth
Basic
teaching programming to liberal arts students; John Kemeny
unit testing
testing a part of the program without the parts surrounding it (ex. Testing a single function of the program)
regression testing
testing during maintenance
beta testing
testing in a production environment (being used in real-world application for which it is designed)
code coverage testing
testing with sufficient data to assure execution of every statement
source code (compilation)
the high-level program; cannot be run on computer; (originates in the high level language; not translated?)
object code (compilation)
the machine language translation of the program; (can be run on computer; result after compiling)
machine language
the only kind of language that can be executed directly by the computer
computer science
the study of algorithms, the related mathematics, and their application to practical computational problems
local variable
variable in the def function that is treated in the main program as if it weren't defined
//
whole number quotient