Scratch Lab #4

Name: Matthew Moorehead

Date: October 8th, 2015

Period: 7

Assignment: Lab #3

Lab Overview

For this problem we had to make a sprite that would be moving, in my case dancing, and have different sprites which controlled how fast the sprite was moving. We needed to use variables to solve the solution including faster and slower sprites.

My Solution

To solve this, I made the sprite continue to dance forever. Then, I made a variable speed and made the faster and slower sprites increase or decrease the speed when clicked. This made the sprite speed up or slow down when told to.

My Project Link

Lab Overview

This problem asked us to design a sprite that asked questions to the user on the computer. It needed to ask 4 questions and then repeat those answers to another sprite. We used variables for this question.

My Solution

To solve this problem, I first made variables for each of the questions that the user ansered. Then I set that variable to its answer and then repeated that to the tell the other sprite the answer of that person. This made them have a conversation.

My Project Link

Lab Overview

For this lab, we had to make an equation whixh found the distance of two different pairs of x and y coordinates. We needed to create variables to do this including 4 variables, one for each coordinate the user chose.

My Solution

To do this, I added four variables, 1st x,2nd x, 1st y, 2nd y. Then, I asked the user of the computer which coordinates they wanted. Then, I made a variable for disance and plugged in the distance formula into it. This answered the distance.

My Project Link

Questions

  1. Are variables in computer programming the same as variables in math class? Why or why not?
    • The variables here are different because in math variables are always numerical intervals while in computer programming there can be any answer to the variable.
  2. When creating a variable, what are the two types of scope a variable can have? That is, what can it affect.
    • The two types of scopes are either that the variable can affect all sprites or for only one sprite.
  3. How many values can a variable store at one time?
    • It can store as many values at one time because the user can change the answer from any answer they want.
  4. What will the following code snippet do? Explain why it doesn’t work as intended.
    • The snippet will have value 1 and value 2 be the same value instead of its intended outcome which is value 1 equals value 2 and value 2 equals value 1.
  5. Given the following code snippet, explain what is happening.
    • In this snippet, the value 1 and value 2 will be reversed and temp will be value 2, making the snippet work.