sweigart chapter 2 Flashcards

1
Q

flow control statement

A

can decide which Phyton instructions to execute under which conditions. they directly correspond to the symbols in a flowchart.

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

Boolean values

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

comparison operators (relational operators)

A

compare two values and evaluate down to a single Boolean value.

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

and operator

A

evaluates an expression to True if both Boolean values are True.

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

or operator

A

evaluates an expression to True if either of the two Boolean values is True. if both are False, it evaluates to False.

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

not operator

A

operates on only one Boolean value (or expression).

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

condition

A

the same thing as an expression, but a more specific name in the context of flow control statements.

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

blocks

A

phyton code can be grouped together in blocks. one can tell where a block begins and ends from the identation of the lines of code.

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

clause

A

a block of code usually following a condition in flow control statements.

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

program execution

A

a term for the current instruction being executed.

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

if statement

A

the most common type of flow control statement. the block follow the if statement is the clause. if the statement condition is True the if statement’s clause will execute. the clause will be skipped if the condition is False.

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

elif statement

A

an ‘else if’ statement that always follows an if or another elif statement. it provides another condition that is checked only if all of the previous conditions were False.

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

while statement/while loop/loop

A

the code in a while clause will be executed as long as the while statement’s condition is True. the program execution jumps back to the start of the while statement at the end of the while clause. the condition is always checked at the start of each iteration.

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

break statement

A

a shortcut to getting the program execution to break out of a while loop’s clause early. if the execution reaches a break statement, it immediately exits the while loop’s clause.

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

continue statement

A

when the program execution reaches a continue statement, the program execution immediately jumps back to the start of the loop and re-evaluates the loop’s condition.

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

for loop

A

can be used if you want to execute a block of code only a certain number of times. after executing the loop’s clause, the execution goes back to the top of the loop.

17
Q

range()

A

one of the functions that can be called with multiple arguments separated by a comma. this lets one change the integer passed to range() to follow any sequence of integers, including starting at a number other than zero.

18
Q

built-in functions

A

a basic set of functions that all Python programs can call, including print(), input(), and len().

19
Q

standard library

A

a set of modules that Python comes with.

20
Q

module

A

a Python program that contains a related group of functions that can be embedded in one’s programs.

21
Q

math module

A

mathematics-related functions.

22
Q

random module

A

random number-related functions.

23
Q

import statement

A

needed before a function in a module can be used. the module must be imported with an import statement.

24
Q

random.randint() function

A

evaluates to a random integer value between the two integers that pass it.

25
Q

sys.exit() function

A

used to terminate or exit the program. this function is from the sys module, so sus has to be imported.