Return to Scratch

Scratch Lab 4

Name: Miles Wiesenthal

Period: 7

Assignment: Lab #4

Lab Overview

This lab focused on variables. We were supposed to use variables to store data and recieve user input. variables help a lot; they make your code more modular, easier to read, and easier to tweak. The three problems I had were to make a system that would use the distance formula to find the distance of something, with user input. I also had to make a guy dancing which got faster when I pressed a button, or slower. And I had to make a song that would increase in volume as I pressed a button, and once the volume got too high, cops would arrive.

My Solution

I decided to combine the second two problems because they were similiar. For the first one I went above and beyond, by creating a graphic interface, showing the coordinates. I made the distance scaled down by ten, to be easier to see, and I made a graphical line and points. To solve it I just input the distance formula with the user input. for the second one I made a variable called speed, which increased or decreased when a button was pressed. For the third one I also had 2 more buttons which increased the volume, which had a detection loop when it got over 99. When it got over 99, it broadcasted a message, to have the other sprites do their thing.

Problem #1,4

Problem #3

Questions

  1. Variables in computer programming are sort of similar to those in algebra, because they both are placeholders for numbers, and both can change and thus change an equation. But they are not the same because you are not trying to solve for them, you set them.
  2. A variable can be a string or a number. If it's a number it can be used in calculations. Either way it can be displayed, or used as a placeholder.
  3. A variable can store one value at a time.
  4. Value 1 will become value 2, and value 2 will stay the same. It doesn't switch them because value 1 becomes value 2 slightly before. You would need a placeholder value.
  5. Value 1 becomes value 2 and value 2 becomes value 1. This happens because value 1 is stored in temp, then it changes to value 2, but temp stays the same. Then value 2 becomes temp, effectively switching them.