Lecture 1 Flashcards
Why give names to values in expressions?
- Reuse names instead of values (imagine having to repeat a flot with 12 digits every time I want to re-use it)
- Make code easier to read and modify
How are expressions evaluated in Python?
What are the values of meters and feet variables after each line is executed?
~~~
meters = 100
feet = 3.2808 * meters
meters = 200
~~~
- meters = 100 and feets does not exist
- meters = 100 and feet = 328.08
- meters = 200 and feet = 328.08
Note that feets is not update after meters has been changed on 3rd l
What is the definition of an algorithm?
It is a finite list of instructions
describing a set of computations that when executed on a set of
inputs will proceed through a sequence of well-defined states and
eventually produce an output.
What is the definition of flow of control?
It is the order in which the instructions from an imperative program is executed.
By default, instructions are executed one after another,** starting from the top. However, we can change this by using, flow control statements (e.g. if
statements).
Explain primitives
Primitives are the building blocks, like atoms, of a programming language.
The primitive constructs in Python include literals (e.g., the number 3.2 and the string ‘abc’) and infix operators (e.g., + and /).
Explain syntax
Syntax determines when the combination of primitives is legal. See examples below in Python
3.2 + 3.2
- syntatically valid3.2 3.2
- not syntatically valid
Explain static semantics
Statics semantics determines that syntatically correct code is meaningful.
3.2 + 'hello world'
is syntatically correct but fails in terms of static semantics
Explain semantics
Semantics is the meaning of code that is both syntatically correct and has proper statics semantics.
Code can only be interpreted in one way by computers.
It can happen that the programmer was not able to convey the desired meaning to the code he/she created, and execution of program by the computer does not yield the expected outcome.
What is the Church-Turing thesis?
Is the thesis that if a problem is computable, then a Turing Machine can compute it.
What is the concept of Turing completeness?
Whenever a proposed programming language is able to simulate a Turing Machine, this language is said to be Turing complete.
The interest part is solution in one Turing-complete programming language can be converted to another as long as the latter is also Turing complete.
What is a flowchart?
It is a visual representation of the flow of control from an imperative program.
What is source code?
It is the code written by the programmer as the programmer was the source for the code written.
What is the difference between interpreted and compiled programming languages?
What is the difference between low-level versus high-level programming languages?