2.1.4 Thinking Logically Flashcards

1
Q

What is Logic

A
  • Use of logical operators to reason the outcome of a given arguement
  • Thinking logically is the process of combining logical operators and data sets to produce logical expressions that represent complex arguments and identify possible outcomes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are examples of some logical operators

A
  • > - Greater Than
  • < - Less than
  • <= - Less than or equal to
  • >= - Greater than or equal to
  • != - Not equal to
  • == - Equals (same as)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do the logical operators: AND, NOT, OR and XOR mean

A
  • AND - Both statements must be true for the argument to be true
  • OR - Only 1 statement has to be true or both for argument to be true
  • XOR - (exclusive OR) - Argument is false if both statements are true or both are false
  • NOT - The opposite of
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When do decisions have to be taken

A
  • Happens during selection, which 1 of a number of alternative paths are chosen based on teh condition of a logical operation.
  • Also during iteration whether or not to repeat a set of instructions
  • Draw a flowchart to identify where decisions need to be taken (see decision diamond) - require logical operators to be used.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you determine the logical conditions that affect the outcome of a decision.

A
  • Can be difficult to determine. The basic methodology is to take the problem or conditions and write them out and rewrite them using logical operators and remove extra text.
  • This process should leave with a logical argument that can be turned into selection or iteration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you determine how decisions affect flow through program

A
  • Determining how decisions affect flow through a program is simple with a flowchart but is hard to choose an implementation method
    • Selection statement represents a single decision but can use else if to code alternative values. Can be nested to give multiple decisions
    • Iteration involves repetition of code. Should look for arrows that loop to earlier instructions. Therefore implemented as an iteration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly