exam 2 Flashcards

1
Q

a ____ is a sequence of statements only executed under a certain condition.

A

branch

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

An ____ branch is a branch taken only if an expression is true.

A

if

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

An ____ branch has two branches: The first branch is executed if an expression is true, else the other branch is executed.

A

if-else

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

The ____ evaluates to True if the left and right sides are equal.

A

equality operator (==)

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

The ____ evaluates to True if the left and right sides are not equal, or different.

A

inequality operator (!=)

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

A ____ is a type that has just two values: True or False.

A

Boolean

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

A ____ checks how one operand’s value relates to another.

A

relational operator

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

Python supports ____. For example, a < b < c determines whether b is greater-than a but less-than c.

A

operator chaining

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

A ____ treats operands as being True or False, and evaluates to True or False.

A

logical operator

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

Logical operators include ____, ____, and ____.

A

AND, OR, NOT

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

____: True when its one operand is False, and vice versa.

A

Logical NOT

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

____: True when at least one of its two operands are True.

A

Logical OR

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

____: True when both of its operands are True.

A

Logical AND

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

A branch’s statements can include any valid statements, including another if-else statement, which are known as ____ statements.

A

nested if-else

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

The order in which operators are evaluated in an expression is known as precedence rules. ____, ____, and ____operators are evaluated in what order.

A

Arithmetic, relational, logical

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

A ____ is a series of statements grouped together.

A

code block

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

____ is any blank space or newline

A

whitespace

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

Program redundancy can be reduced by creating a grouping of predefined statements for repeated operations, known as a ____.

A

function

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

A ____ is a named series of statements.

A

function

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

A ____ consists of the function’s name and a block of statements.

A

function definition

21
Q

A ____ is an invocation of the function’s name, causing the function’s statements to execute.

A

function call

22
Q

The ____ keyword is used to create new functions.

A

def

23
Q

____ is a special keyword that indicates no value.

A

None

24
Q

A ____ is a function input specified in a function definition.

A

parameter

25
Q

An ____ is a value provided to a function’s parameter during a function call.

A

argument

26
Q

Code such as user_input = int(input()) consists of such a hierarchical function call, in which the input() function is called and evaluates to a value that is then passed as an argument to the int() function.

A

hierarchical function calls or nested function calls

27
Q

A function with no return statement is called a ____, and such a function returns the value None.

A

void function

28
Q

A variable or function object is only visible to part of a program, known as the object’s ____.

A

scope

29
Q

variables defined inside a function are called____.

A

local variables

30
Q

a variable defined outside of a function is called a ____.

A

global variable

31
Q

A ____ statement must be used to change the value of a global variable inside of a function.

A

global

32
Q

The function’s behavior of adding together different types is a concept called ____

A

polymorphism

33
Q

Python uses ____ to determine the type of objects as a program executes.

A

dynamic typing

34
Q

In contrast to dynamic typing, many other languages like C, C++, and Java use ____, which requires the programmer to define the type of every variable and every function parameter in a program’s source code.

A

static typing

35
Q

____ is an operation that allows a statement to perform multiple assignments at once to variables in a tuple or list.

A

Unpacking

36
Q

A ____ is a string literal placed in the first line of a function body.

A

docstring

37
Q

A ____ statement loops over each element in a container one at a time, assigning a variable with the next element that can then be used in the loop body.

A

for loop

38
Q

A for loop may also iterate backward over a sequence, starting at the last element and ending with the first element, by using the ____ function to reverse the order of the elements.

A

reversed()

39
Q

____ generates a sequence of integers between a starting integer that is included in the range, an ending integer that is not included in the range, and an integer step value.

A

range()

40
Q

A ____ is a construct that repeatedly executes an indented block of code (known as the loop body) as long as the loop’s expression is True.

A

while loop

41
Q

Each execution of the loop body is called an ____, and looping is also called ____.

A

iteration, iterating

42
Q

____, a value that when evaluated by the loop expression causes the loop to terminate.

A

sentinel value

43
Q

An ____ is a loop that will always execute because the loop’s expression is always True.

A

infinite loop

44
Q

The programmer can use a variable to count the number of iterations, called a ____.

A

loop variable

45
Q

A ____ is a loop that appears as part of the body of another loop.

A

nested loop

46
Q

The nested loops are commonly referred to as the ____ and ____.

A

outer loop, inner loop

47
Q

A ____ statement in a loop causes the loop to exit immediately.

A

break

48
Q

A ____ statement in a loop causes an immediate jump to the while or for loop header statement.

A

continue