Evaluating process: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
Line 5: Line 5:
'''A common scenario is evaluating the order of conditionals. You must become very good at tracing conditional expressions.'''
'''A common scenario is evaluating the order of conditionals. You must become very good at tracing conditional expressions.'''


You should remember your order of operations.
You should remember your order of operations:


In mathematics and computer programming, the order of operations (or operator precedence) is a collection of rules that reflect conventions about which procedures to perform first in order to evaluate a given mathematical expression.<ref>https://en.wikipedia.org/wiki/Order_of_operations</ref>
In mathematics and computer programming, the order of operations (or operator precedence) is a collection of rules that reflect conventions about which procedures to perform first in order to evaluate a given mathematical expression.<ref>https://en.wikipedia.org/wiki/Order_of_operations</ref> The mathematical order of operation is: PEMDAS (


== How to evaluate a process ==
Use a step-by-step process and '''trace''' the value of a variable or value.  Ask yourself, at each step in the process, what is the current value or state of a variable. Let's look at some examples.
=== Example ===
Imagine you are writing a simple computer program which must output who is the winner of a game. The input is two scores. The output must be only one of the scores below:
# The first score is the winner
# The second score is the winner
# There is a tie
<syntaxhighlight lang="python">
def whoIsTheWinner(score1, score2):
    if(score1 > score2):
        winner = "The first score is the winner"
    elif(score2 > score1):
        winner = "The second score is the winner"
    else:
        winner = "There is a tie"
</syntaxhighlight>


== Do you understand this? ==




== Do you understand this? ==





Revision as of 13:19, 15 July 2017

Evaluating process[1]

You must evaluate if the sequence of activities (or instructions) will result in the required outcomes. This evaluation can be logical, arithmetic, or both.

A common scenario is evaluating the order of conditionals. You must become very good at tracing conditional expressions.

You should remember your order of operations:

In mathematics and computer programming, the order of operations (or operator precedence) is a collection of rules that reflect conventions about which procedures to perform first in order to evaluate a given mathematical expression.[2] The mathematical order of operation is: PEMDAS (

How to evaluate a process[edit]

Use a step-by-step process and trace the value of a variable or value. Ask yourself, at each step in the process, what is the current value or state of a variable. Let's look at some examples.

Example[edit]

Imagine you are writing a simple computer program which must output who is the winner of a game. The input is two scores. The output must be only one of the scores below:

  1. The first score is the winner
  2. The second score is the winner
  3. There is a tie
def whoIsTheWinner(score1, score2):
    if(score1 > score2):
        winner = "The first score is the winner"
    elif(score2 > score1):
        winner = "The second score is the winner"
    else:
        winner = "There is a tie"


Do you understand this?[edit]

Standards[edit]

  • Evaluate whether the order in which activities are undertaken will result in the required outcome.

References[edit]