Scratch Lab 4

Pair Programming

Problem #1-Quick Costume Change

Problem #2-A.I.

Problem #5-Metric Converter

Questions

#1 Are variables in computer programming the same as variables in math class? Why or why not?

No. For example, if X is a variable. The equation X=X+4 does not make sense mathematically, but to a computer it will set a new value for X equal to the old X value plus 4.

#2 When creating a variable, what are the two types of scope a variable can have? That is, what can it affect. (Think about your options as you make a variable)

The variable can affect all pieces of code (sprites) or only one piece of code (sprite).

#3 How many values can a variable store at one time?

A variable can store only one value at a time.

#4 What will the following code snippet do? Explain why it doesn’t work as intended.

Variables always have to have a value in them, and this code switches them both at once which doesn't work. Another variable is needed to store a value so the varibles can switch their values one at a time.

#5 Given the following code snippet, explain what is happening.

A variable "temp" is being set to the variable "value_1". "value_1" can then be set to "value_2" and after that "value_2" can be set to temp, which is the old value of "value_1". Effectively the values of "value_1" and "value_2" were switched.