part 4, patterns, algorithms and programs 1 Flashcards
- Start with an if statement
- Use elif statements there after
- Use an else statement as the last statement. This acts as a catch all and does not evaluate any boolean expressions
describe the 3 steps of using pythons elif statement
what are the 3 steps of the formula problem pattern

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
when testing code what is the first thing you should think about for the test values
by applying this pattern template to an algorithm we can implement selection between two different cases
what does the case analysis (two cases) pattern allow
- negation (NOT)
- conjunction (AND)
- disjunction (OR)
what are the three most used boolean operations
when testing code what is the first thing you should think about for the test values
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
what is floor division
this divides a given number by another given number and then rounds the quotient down to the nearest integer and returns this value

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

this operation finds out how many times the second number goes into the first and then returns the remainder
what does pythons modulus operator do
when can we apply the formula problem pattern
this can be applied to an algorithm when one or more inputs can directly calculate one output

name some comparison operators in python
what are the three most used boolean operations
- negation (NOT)
- conjunction (AND)
- disjunction (OR)
when testing code what is the second thing you should think about
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

what are the 9 steps of the problem solving workflow when using pattern templates
this divides a given number by another given number and then rounds the quotient down to the nearest integer and returns this value
what is floor division
when using this. on the last else statement you should include what it will catch but comment it out

when using pythons elif statement what is good practice for the last else statement
this can be applied to an algorithm when there is a value that changes with every iteration and the last iteration is unknown
when can we apply the sequence generation pattern to an algorithm
what is pythons floor division operator
to accomplish this task use //
example
10 // 4
when would you use pythons elif statement
this can be used in python when you would like to apply nested statements
what are the 11 lines of the case analysis (nested case) pattern

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

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

name some comparison operators in python

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
what are the 9 steps of the problem solving workflow when using pattern templates

this can be used in python when you would like to apply nested statements
when would you use pythons elif statement
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
when expresssed as a problem and sub problems what are the 4 steps of the sequence generation pattern

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


what are the 11 lines of the case analysis (nested case) pattern
what is the syntax for pythons modulus operator
to perform this operation in python use
%
example
10 % 4 = 2
10 - 8 = 2
to accomplish this task use //
example
10 // 4
what is pythons floor division operator

when expresssed as a problem and sub problems what are the 4 steps of the sequence generation pattern
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
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
describe the 3 steps of using pythons elif statement
- Start with an if statement
- Use elif statements there after
- Use an else statement as the last statement. This acts as a catch all and does not evaluate any boolean expressions
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
to perform this operation in python use
%
example
10 % 4 = 2
10 - 8 = 2
what is the syntax for pythons modulus operator
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

what are the 6 steps of the sequence generation pattern