6.00.1x & 6.00.2x Flashcards
imperative vs. declarative knowledge
declarative - statement of facts
imperative - recipe or “how-to” computation
What is the difference between a program and a algorithm?
An algorithm is a conceptual idea, a program is a concrete instantiation (representation?) of an algorithm.
A computational mode of thinking means that everything can be viewed as a math problem involving numbers and formulas.
True or False ?
True
Computer Science is the study how to build efficient machines that run programs.
True or False ?
False
What does it mean when we say that “the computer walks through the sequence executing some computation”?
The computer executes the instructions mostly in a linear sequence, except sometimes it jumps to a different place in the sequence.
What are primitive operations and what are some examples of primitive operations ?
Where are they in a computional machine?
A low-level object or operation from which higher-level, more complex objects and operations can be constructed.
Examples: addition, subtraction, examine true or false statements
In the ALU - arithmetic logic unit
What “Determines whether a string is legal”?
syntax
What “determines whether a string as meaning”?
semantic syntax
What “assigns a meaning to a legal sentence”?
semantics
What is the output after each expression ?
Remember this is one session - each expression is calculated directly after the previous problem.
- 5.0 and float
- 4.0 and float
- none type and error
What sort of expression is this ?
and what value is returned ?
Bool
True
print(ss[-4:-1])
How do you read slicing strings with negative index numbers ?
Same as positive
Read from left to right
remember starting value is inclusive
ending value is exclusive
What is the significance of the stride in slicing ?
it allows you to choose the interval at which python takes parts when slicing
How do you print in reverse order using slicing ?
Double colon to signify that this applies to the whole string
and then have -1 as the stride value.
What is the return value of this piece of code ?
and why?
Hot
because the computer reads the code in a linar fashion and the value meets the if statement to ‘print’ HOT.
What does += mean?
add whatever number to the varaible that is attached to it
mysum += i
What is a recipe?
- Sequence of simple steps
- Flow of control process that specifies when each step is executed
- A means of determining when to stop
How many primitives do you need to do any calculation
6
What are expressions ?
complex but legal combinations of primiives in a programming language
What could go wrong when writing a program ?
Syntactic errors
Static syntactic errors
No semantic error but different meaning to what the programmer intended
The difference between static semantics and semantics?
A statement in python may have meaning (it is statically semantically correct), but it may not do what you intended (it is not semantically correct).
List all the operations on ints and floats
How do you bind a value to a variable ?
Using the equals sign
e.g. pi = 3.14159
What are the comparison operators for Ints and Floats ?
Why is an indentation important?
Each indented set of expressions denotes a block of instructions.
Indentations also provide a visual structure that reflects the semantic structure of the program.
What is a Branching program ?
The simplest branching statement is a conditional
A test ( an expression that evaluates to true or false )
A block of code to execute if the test is true
An optional block of code to execute if the test is false
What is a nested conditional?
That inside a block, you have another conditional
What does ‘control flow - branching’ do?
evaluates expressions in blocks if <condition> is <strong>True</strong></condition>