Scratch Lab #4 Write Up

Name: Lexi Williams

Period: 7

Assignment: Lab #4

Lab Overview

This lab focused on variables and how to use them. This lab required me to mess around with the variables and teach myself how to use the variables in different ways. I had to make sprites talk to each other with information already given to the first sprite which is where the variable comes in. I also had to learn how to make a variable that when clicked would execute the action coded for it.

My Solution

My solution included creating a sprite (the crab) that would ask questions. Based on the variables given, when the new sprite (the fish) appeared the two sprites would have a converstaion about who the crab just met. I used variables, I broadcasted messages, and asked questions.

My Project Link

My solution for this problem was creating a sprite that would change costume, and I just flipped it, then I had to wait for the variable 'speed' seconds in order for the actual sprite to change it's costume. I then had to add two buttons that would speed up the sprite and slow down the sprite. The variable speed when the specific button sprite was clicked would either slow down by 0.2 seconds or speed up by -0.2 seconds.

My Project Link

My solution to this problem was very difficult. I had to play around with everything just to get it the way I needed to to be. I first had to make three different sprites who danced, and in order to do this I switched their costumes every 0.2 seconds and put that in a forever loop. I then had to create another sprite that controlled the volume. This sprite and the code I put in to determine when it was too loud would bring in the police to stop the party. The code for the volume sprite would change volume by 5 and if the volume reached greater than 75 it would broadcast a message to the police who would then come in to stop the party because the music was too loud.

My Project Link

Questions

  1. Are variables in computer programming the same as variables in math class? Why or why not?
    • No, because variables in computer programming are not part of an equation or formula whereas mathematic variables are. Variables in computer are part of a repetitive process.
  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)
    • When creating a sprite the two types of scope a variable can have is that the variable affects all sprites or just the selected sprite.
  3. How many values can a variable store at one time?
    • Variables can only hold one vaule at a time.
  4. What will the following code snippet do? Explain why it doesn’t work as intended.
    • The following code will create a loop of going from value 1 to value 2 then value 2 to value 1.
  5. Given the following code snippet, explain what is happening.
    • This will also create another loop between all the different variables.