7.2 Sequence And Selection Flashcards

1
Q

What are 3 basic control structures used in programming?

A

Sequence, selection and iteration

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

Sequence

A

The statements are executed one by one in the order they are written

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

Selection

A

Declared by an if statement. If the statement is true than the code executed will be the one with the true value.

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

==

A

Equals to

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

!=

A

Not equals to

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

>

A

Greater than

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

Less than

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

> =

A

Greater than or equal to

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

<=

A

Less than or equal to

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

Nested if statements are…

A

If statements inside if statements

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

AND

A

Returns true if both conditions are true

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

OR

A

Returns true if either of the conditions are true

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

NOT

A

The opposite of the given input (true -> false, false-> true)

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

Switch/case statement is used when…

A

A selection is to be made from several alternatives, for example when choosing from a menu

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

How could you simulate a dice throw with the ‘random’ module?

A

import random

throw = random.randint(1, 7) #1 because we want it to start on 1 and 7 because python
#counts to the number before the inputted number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly