# 7.2 Sequence And Selection Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are 3 basic control structures used in programming?

A

Sequence, selection and iteration

2
Q

Sequence

A

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

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.

4
Q

==

A

Equals to

5
Q

!=

A

Not equals to

6
Q

>

A

Greater than

7
Q
A

Less than

8
Q

> =

A

Greater than or equal to

9
Q

<=

A

Less than or equal to

10
Q

Nested if statements are…

A

If statements inside if statements

11
Q

AND

A

Returns true if both conditions are true

12
Q

OR

A

Returns true if either of the conditions are true

13
Q

NOT

A

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

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

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```