part 4, patterns, algorithms and programs 1 Flashcards

1
Q
  1. Start with an if statement
  2. Use elif statements there after
  3. Use an else statement as the last statement. This acts as a catch all and does not evaluate any boolean expressions
A

describe the 3 steps of using pythons elif statement

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

what are the 3 steps of the formula problem pattern

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

the first thing to think about here is what inputs are admissible

example

are only positive integers allowed

is there a minimum or maximum input value

A

when testing code what is the first thing you should think about for the test values

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

by applying this pattern template to an algorithm we can implement selection between two different cases

A

what does the case analysis (two cases) pattern allow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. negation (NOT)
  2. conjunction (AND)
  3. disjunction (OR)
A

what are the three most used boolean operations

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

when testing code what is the first thing you should think about for the test values

A

the first thing to think about here is what inputs are admissible

example

are only positive integers allowed

is there a minimum or maximum input value

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

what is floor division

A

this divides a given number by another given number and then rounds the quotient down to the nearest integer and returns this value

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

what are the 6 steps of the case analysis (two cases) pattern

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

what are the 6 steps of the sequence generation pattern

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

this operation finds out how many times the second number goes into the first and then returns the remainder

A

what does pythons modulus operator do

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

when can we apply the formula problem pattern

A

this can be applied to an algorithm when one or more inputs can directly calculate one output

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

name some comparison operators in python

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

what are the three most used boolean operations

A
  1. negation (NOT)
  2. conjunction (AND)
  3. disjunction (OR)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

when testing code what is the second thing you should think about

A

at this stage you should think about any borderline values and what they will be

example

was there a minimum or maximum input value

can input be positive and negative

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

what are the 9 steps of the problem solving workflow when using pattern templates

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

this divides a given number by another given number and then rounds the quotient down to the nearest integer and returns this value

A

what is floor division

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

when using this. on the last else statement you should include what it will catch but comment it out

A

when using pythons elif statement what is good practice for the last else statement

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

this can be applied to an algorithm when there is a value that changes with every iteration and the last iteration is unknown

A

when can we apply the sequence generation pattern to an algorithm

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

what is pythons floor division operator

A

to accomplish this task use //

example

10 // 4

20
Q

when would you use pythons elif statement

A

this can be used in python when you would like to apply nested statements

21
Q

what are the 11 lines of the case analysis (nested case) pattern

A
22
Q

when can we apply the sequence generation pattern to an algorithm

A

this can be applied to an algorithm when there is a value that changes with every iteration and the last iteration is unknown

23
Q
A

what are the 3 steps of the formula problem pattern

24
Q

what are the 6 steps of the case analysis (two cases) pattern

A
25
Q

name some comparison operators in python

A
26
Q

what does pythons modulus operator do

A

this operation finds out how many times the second number goes into the first and then returns the remainder

27
Q

what are the 9 steps of the problem solving workflow when using pattern templates

A
28
Q

this can be used in python when you would like to apply nested statements

A

when would you use pythons elif statement

29
Q

when can the case analysis (nested cases) pattern be implemented into an algorithm

A

this can be implemented inside an algorithm when you have an input that is mutually exclusive to all other cases

30
Q

when expresssed as a problem and sub problems what are the 4 steps of the sequence generation pattern

A
31
Q

at this stage you should think about any borderline values and what they will be

example

was there a minimum or maximum input value

can input be positive and negative

A

when testing code what is the second thing you should think about

32
Q

this can be applied to an algorithm when one or more inputs can directly calculate one output

A

when can we apply the formula problem pattern

33
Q

when using pythons elif statement what is good practice for the last else statement

A

when using this. on the last else statement you should include what it will catch but comment it out

34
Q
A

what are the 11 lines of the case analysis (nested case) pattern

35
Q

what is the syntax for pythons modulus operator

A

to perform this operation in python use

%

example

10 % 4 = 2

10 - 8 = 2

36
Q

to accomplish this task use //

example

10 // 4

A

what is pythons floor division operator

37
Q
A

when expresssed as a problem and sub problems what are the 4 steps of the sequence generation pattern

38
Q

this can be implemented inside an algorithm when you have an input that is mutually exclusive to all other cases

A

when can the case analysis (nested cases) pattern be implemented into an algorithm

39
Q

when multiple boolean operators are being used within one expression what is the best practice for writing the expression

A

the best practise here is to include brackets inside the expression. this makes it clear when reading to see the order of evaluation

40
Q

describe the 3 steps of using pythons elif statement

A
  1. Start with an if statement
  2. Use elif statements there after
  3. Use an else statement as the last statement. This acts as a catch all and does not evaluate any boolean expressions
41
Q

the best practise here is to include brackets inside the expression. this makes it clear when reading to see the order of evaluation

A

when multiple boolean operators are being used within one expression what is the best practice for writing the expression

42
Q

to perform this operation in python use

%

example

10 % 4 = 2

10 - 8 = 2

A

what is the syntax for pythons modulus operator

43
Q

what does the case analysis (two cases) pattern allow

A

by applying this pattern template to an algorithm we can implement selection between two different cases

44
Q
A

what are the 6 steps of the sequence generation pattern

45
Q
A