OLI Course Flashcards

1
Q

What is computation?

A

a sequence of steps that can be executed by a computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a computer’s instruction set?

A

The primitive instructions a computer knows how to execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the SYNTAX of a programming language?

A

rules that determine what expressions are well-formed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are semantics of a programming language?

A

associating meaning with expressions (?)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A LOW-LEVEL programming language is ____

A

closer to the instruction set of the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A HIGH-LEVEL programming language is closer to ___

A

natural language of humans

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an interpreter?

A

a special program that converts high-level programming language instructions into low-level ones that can be executed by the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An interpreter combines what 2 phases?

A
  • translation to machine language
  • execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is imperative programming?

A

computation is described by a sequence of commands that change the state of data objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What data type represents real numbers?

A

FLOAT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What data type contains a number with decimals?

A

FLOAT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is the type STRING represented in Python?

A

single OR double quotes (use double for better transfer to other languages)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What type is returned by i / j (division) in Python?

A

ALWAYS A FLOAT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is meant by 100 // 50 in Python - what is it called, and what does it return?

A

integer (floor) division
returns 2 - the quotient as an integer, ignoring any remainder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is 50 // 100 in Python?

A

0 - the integer quotient, ignoring any remainder

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is data type and value is 3e4 in Python?

A

FLOAT! 30000.0

17
Q

Why does -15//10 evaluate to -2 in Python?

A

In Python, floor division rounds DOWN to a lesser-value integer.

18
Q

How is Boolean false represented in Python?

A

False

19
Q

What is the assignment symbol in Python?

A

=
For example, x = 10 means that the value 10 is assigned to the variable named x

20
Q

What is the syntax for string concatenation?

A

+
“Susan” + “ “ + “Klefstad”

21
Q

What does the * do when used with a string?

A

concatenates int n copies of the string

22
Q

What is the difference between an expression and a statement?

A

an expression denotes a value, or evalutates operators to return a value
a statement is a command or instruction (like assignment) that changes the state of the computer (memory)

23
Q

What keyword is used to define a function?

A

def
def function_name (list of formal parameters):
function body

24
Q

What is the difference between parameters and arguments?

A

parameters are used in function definition, while arguments are the actual values bound during execution

25
Q

What syntax is required for a function body?

A

It must be indented

26
Q

What is the syntax for a comment in Python?

A

#

27
Q

A return statement can only be used where?

A

in the body of a function definition

28
Q

What are the syntax rules for indentation of a function body?

A

must be indented, any amount (customary 4 spaces), but all the SAME amount

29
Q

If there is no explicit value returned by a function, what does it return?

A

the special value called None

30
Q

What does -15//10 evaluate to in Python?

A

-2
because integer/floor division in Python always rounds down to a lesser number

31
Q

What does 15//10 evaluate to in Python?

A

1
because 1.5 rounds DOWN to the lesser integer

32
Q

What is a module in Python?

A

a file containing related definitions and statements, ending in .py and can be imported (without the .py)

33
Q

In Python, what does the function range(4) do?

A

creates a sequence of 4 integers, 0 1 2 3