Chapter 3 - Branching, While loops and programming Flashcards

1
Q

pick a random number

A

random. randint(1, 6)

random. randrange(6) + 1 -> random number between 6 numbers(0, 1, 2, 3, 4, 5); if (6) + 1 -> (1, 2, 3, 4, 5, 6)

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

a combination of functions, combined for a specific purpose

A

module

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

access randint through the function

A

random.randint()

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

module.function

A

dot notation

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

taking one path instead of another

A

branching

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

an expression that is either True or False

A

condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
== equal to
<= smaller or equal to
>= bigger or equal to
!= different to
A

comparison operators

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

one or more lines with the same indentation

A

block

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

how many statements can be executed in an if-elif-else code

A

1, the first one where the condition is True (or if none evaluate to True then the else statement)

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

if statement but…

A

elif or else clauses

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

a value compared to other values in a condition

A

sentry variable (needs to be initialised before the loop)

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

simulate (go through) the code without running it

A

Tracing

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

which number /and string evaluate to False?

A
Zero 0(e. g. if money:  === if money != 0) !negative numbers are True
empty string ""
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

statement that returns you to the top of the loop

A

continue

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

statement to end a loop

A

break

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

a loop that is meant to be infinite

A

intentional infinite loop(e. g. while True:)

17
Q

a combination of simple conditions (e. g. x > 20)

A

compound condition

18
Q

password = “”
while not password:
password = input(“Password: “)

A

while loop

meaning: while password is False:

19
Q

A set of clear and easy-to-follow instructions for achieving a specific task

A

Algorithm

20
Q

something between English and a programming language

A

pseudocode

21
Q

turning each step into detailed instructions

A

stepwise refinement