T7 - Sequence/Selection and Iteration Flashcards

1
Q

Three operators used in Boolean expressions?

A

AND, OR, NOT

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

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
3
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
4
Q

Selection -

A

next statement to be executed depends on whether the condition being tested is True or False

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

selection eg

A

Eg if statements (allow different branches to be executed based on the result of a Boolean expression)

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

==

A

equal to

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

!=

A

not equal to

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

>

A

greater than

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

greater than or equal to

A

> =

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

<

A

lesser than

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

lesser than or equal to

A

<=

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

AND

A

return as true if both conditions are true

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

OR

A

returns as true as long as one is true

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

NOT

A

returns the opposite value

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

Random numbers:
in Python,

A

import random to access library (numbers)
or
random.randint(0, 100) to generate range

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

random numbers - Pseudocode

A

random(0, 100)

17
Q

To generate a decimal number

A

use range -100.0 and 100.0,

18
Q

Iteration

A
  • repetition of a section of code
19
Q

iteration eg

A

Eg:
for … next
while … endwhile
do … until (not in python)

20
Q

For loops -

A

when you want to execute the loop a specified number of times
Use i in rage

21
Q

While loops -

A

when you want to execute the loop while a certain condition is true.

22
Q

infinite loop -

A

If a loop continues forever and there is no way to exit it

23
Q

while loop is tested when

A

the condition is tested at the beginning of the loop

24
Q

do … until loops:

A

when you want to execute the loop until a certain condition is True

25
Q

do … until loops: tested when

A

The condition is tested at the end of the loop