Let the machine guess something, check, go back, change a parameter, check again etc. until answer arrives.
Back
While loop
Front
Will do the same thing over and over as long as something is true.
Back
Variable
Front
Back
Declarative knowledge
Front
statements of fact
Back
Turing showed you can compute ___
Front
Anything using 6 primitives: move left, move right, scan, print, erase, do nothing
Back
5 Scalar objects
Front
int - represents integers
float - represents real numbers ex 3.27
bool - represent Boolean values True and False
Nonetype - special and has one value, none
Back
Objects come as either _____ or non ________
Front
Scalars, which can't be subdivided, or non-scalars which have internal structure out of which we can pull parts.
Back
modulo (%) operator
Front
returns the integer remainder of the division. dividend % divisor = remainder.
Back
What is the difference between an Algorithm and a Program?
Front
An algorithm is a conceptual idea, a program is a concrete instantiation of an algorithm.
Back
Comparison operators on int and float
Front
i>j
i>=j
i<j
i<=j
i==j
i!=j
Back
What are the two things that computers do?
Front
Perform calculations and remember things
Back
What are the fundamental primitives that represent data?
Front
Objects.
Back
input
Front
keyword which takes your input for a string and applies it to a variable
Back
if-else expressions
Front
if this is true: do this
if not: else
Back
Fixed program computer
Front
made for one purpose only
Back
Definitions
Front
ways of assigning names to values or creating procedues that we're going to treat as if they are primitives
Back
stored program computer
Front
emulates fixed program computer in one convenient machine, a sequence of instructions built out of simple arithmetic and logic
Back
Why would you use "print" command
Front
If you want to see something out in the shell instead of adding to computation
Back
Elif
Front
IF this is true, do this. But if it is false, do this other thing.
if x < y and x < z
print ('x is least')
elif y< z:
print ('y is least')
Back
ALU
Front
Arithmetic Logic Unit one of two parts of basic machine - does primitive operations, testing true or false statements
Back
Static Semantics
Front
about meaning of sentence. Answers question: is sentence valid, what does it mean. If it is correct it will pass the static semantics test, but not necessarily be "semantic" in that it is the meaning you meant for it to have.
Back
Nested conditionals
Front
putting an if/else statement inside an if/else statement
Back
Compound booleans
Front
Back
range
Front
Back
a+= b is equivalent to
Front
a = a + b
Back
str1 = 'hello'
Front
assigns variable "str1" with definition 'hello'
Back
operator for int division
Front
i//j returns quotient without remainder
Back
break
Front
stops execution of code at that point, and out of a loop.
Back
For loop
Front
known number of times it's going to run through iterations
can end early via break
uses a counter
can rewrite a for loop using a while loop
Back
Every object has a ____ associated with it
Front
Type. tells programs whether they can act on it or not.
Back
Syntax
Front
about structure or grammar of language. Answers question: how do I construct valid sentence
Back
a /= b is equivalent to
Front
a = a / b
Back
Logic operators on bools
Front
a and b are any variable names:
not a :
a and b -> true if both are true
a or b -> true if either or both are true
Back
print(x)
Front
prints just the value of the variable 'x'
Back
branching program simply consists of ___
Front
a test, which returns a boolean true or false.
If true, has code to say what to do in that case.
If false, has code to say what to do in that case.
Back
Commands
Front
simple expressions that can be executed directly within python
Back
a *= b is equivalent to
Front
a = a * b
Back
a -= b is equivalent to
Front
a = a - b
Back
mysum = 0
for i in range(7,10):
mysum + = i
print(mysum)
Front
24 (seven, eight, nine, added)
Back
one = 1
two = 2
hello = "hello"
print(one + two + hello)
Front
Won't work, can't combine strings and integers.
Back
mysum = 0
for i in range(5, 11, 2):
mysum += 1
Front
21 (5 + 7 + 9)
Back
operator precedence order
Front
**
*
/
+ and -
executed left to right
Back
operator for finding power of int or float
Front
i**j
Back
Order of boolean operations
Front
1. Parentheses, before operating anything else.
2. not statements
3. and statements.
4. or statements
Back
Binding variables order
Front
if you bind x = 2,
then have x = x * x
x now = 4
Back
imperative knowledge
Front
Directions
Back
How many calculations can a computer do in 1 second?
Front
A billion roughly
Back
tuple
Front
Back
The shell
Front
the current workspace.
Back
Control Unit
Front
Two of two parts of basic machine - keeps track of what specific operation doing in ALU at each point in time.
Back
Section 2
(8 cards)
exhaustive enumeration
Front
Exhaust all possible options
Back
bisection search
Front
Ex. needing to find a number:
1. Picking a random number, seeing if it's too big or too small.
2. If it's too big, discount any number bigger, if too small, discount any number smaller.
3. pick another random number in new range, and repeat.