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

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

25
name some **comparison operators** in python
26
what does pythons **modulus** operator do
this operation finds out how many times the second number goes into the first and then returns the remainder
27
what are the 9 steps of the **problem solving workflow** when using pattern templates
28
this can be used in python when you would like to apply nested statements
when would you use pythons **elif** statement
29
when can the **case analysis (nested cases) pattern** be implemented into an algorithm
this can be implemented inside an algorithm when you have an input that is mutually exclusive to all other cases
30
when expresssed as a problem and sub problems what are the 4 steps of the **sequence generation pattern**
31
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
when **testing code** what is the **second thing** you should think about
32
this can be applied to an algorithm when one or more inputs can directly calculate one output
when can we apply the **formula problem pattern**
33
when using pythons elif statement what is good practice for the last else statement
when using this. on the last else statement you should include what it will catch but comment it out
34
what are the 11 lines of the **case analysis (nested case)** pattern
35
what is the **syntax for pythons modulus operator**
to perform this operation in python use % _example_ 10 % 4 = 2 10 - 8 = 2
36
to accomplish this task use // _example_ 10 // 4
what is **pythons floor division operator**
37
when expresssed as a problem and sub problems what are the 4 steps of the **sequence generation pattern**
38
this can be implemented inside an algorithm when you have an input that is mutually exclusive to all other cases
when can the **case analysis (nested cases) pattern** be implemented into an algorithm
39
when **multiple boolean operators are being used within one expression** what is the best practice for writing the expression
the best practise here is to include brackets inside the expression. this makes it clear when reading to see the order of evaluation
40
describe the 3 steps of using **pythons elif statement**
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
the best practise here is to include brackets inside the expression. this makes it clear when reading to see the order of evaluation
when **multiple boolean operators are being used within one expression** what is the best practice for writing the expression
42
to perform this operation in python use % _example_ 10 % 4 = 2 10 - 8 = 2
what is the **syntax for pythons modulus operator**
43
what does the **case analysis (two cases)** pattern allow
by applying this pattern template to an algorithm we can implement selection between two different cases
44
what are the 6 steps of the **sequence generation pattern**
45