MIT 6.00 Week 1 Flashcards
What are the two kinds of knowledge?
Declarative and imperative
What is declarative knowledge?
Statements of fact.
What is imperative knowledge?
Knowledge of how to do something, instructions to accomplish a task.
Algorithm
A description of how to perform a computation
What is it called when an algorithm has halted?
The algorithm has converged.
What is flow control?
An order of execution for the steps of an algorithm
The condition under which the algorithm stops
termination condition
What kind of computer is hard coded to do a certain set of calculations?
Fixed program computer
What kind of computer treats both input and the commands to manipulate that input as data?
Stored program computer.
Why two primary ways that stored program computers are superior to fixed program computers
They are infinitely flexible
They allow programs to create programs
What is the interpreter?
A program that can execute any valid set of instructions
Alan Turing proved that:
With 6 primitive instructions you can do anything that can be done with a computer (rough)
What determines the difference between different programming languages?
Instructions
Flow control
What are the three characteristics of a programming language?
Syntax
Static semantics
Semantics
Syntax:
What sequence of characters and symbols constitute a well formed string.
Static Semantics
Provides restrictions on syntactically correct expressions to ensure that the expression is meaningful
Semantics
Provides rules for the meaningful interpretation of a syntactically correct expression
What are the possible negative consequences of running a program?
Crash
Infinite loop
Run to completion with an incorrect answer
What process does a program written in an interpreted language go through when it is run?
source code - checker - interpreter - output
What process does a program written in a compiled language go through in order to be run?
source code - checker/compiler - object code - interpreter - output
What is the IDE (Integrated Development Environment) for Python?
IDLE
What is an object in Python?
Everything
What does an object’s type tell us?
What it is an what we can do with it
Types break down into what two categories?
Scalar
Non-Scalar
What kind of type is indivisible (for the most part)
Scalar
What are the Scalar Types?
Integer -int Float -float Boolean -bool None -NoneType String -str
What type does Python not have that most programming languages do?
Character
-char
In Python, how is the literal of a string denoted?
Bye single quotes or double quotes
‘ ‘
“ “
Define expression
A sequence of operators, operands, and functions
When is an operator overloaded?
When it has different meanings depending on the operands it is working on
What is concatenation?
Sticking two things together
Why is computation between numbers of different types complicated?
An int divided by an int will produce an int result, which might truncate the remainder
How do you change type?
typename(input)
Example: str(3)
int(2.5)
How are comments marked in Python?
#
what command prints to the screen?
In Python, what is variable?
a name for an object?
In Python, what does an assignment statement do?
Binds a name to an object
what are the two input commands in Python 2.X?
raw_input(“prompt”)
input(“prompt”)
what type does raw_input return by default?
a string
How do you find the type of an object?
type()
What is the name of a program wherein each line of code is executed exactly once?
A straight line program
What are the conditionals in Python?
else
if
elif
What is the function of indentation in Python?
Indentation determines how code is associated to other code. Code indented to a conditional will only execute with that conditional.
Code not indented will always execute
What is the name of a program wherein there are multiple paths that the program can follow depending on conditions, before returning to the main line?
A branching program
What is the name of a program wherein code can be executed multiple times based on iteration?
A looping construct or program
What kind of program is considered Turing complete?
A looping program
How do you find the absolute value?
abs()
What are the operations in Python?
Addition \+ Subtraction - Multiplication * Division / Exponentiation ** Modulo % For ints only
What are the comparison operations in Python?
Less than < Greater than > Less than or equal to = Does not equal != Does equal ==
What do comparison operations always return?
A boolean value
What are the boolean operators in Python?
And
Not
Or
How many operands are needed for each boolean operator?
And - 2
Or - 2
Not - 1