Do Now 2.5 Variables Practice

  1. Write an algorithm, in English, for how you would swap the values in two variables.

    For example, suppose we have two variables that have different values:

    set [playerOneValue] to “Torch”

    set [playerTwoValue] to “Gold”

    How would you swap the values so [playerOneValue is] set to “Gold” and [playerTwoValue] is set to “Torch”?

    Here, “Torch” and “Gold” are just examples – suppose the algorithm doesn’t know what values the variables have before it begins.

  2. Swap your algorithm with a partner and test it to determine if it works or not.