Name: Kelly Yokoi
Period: 7
Assignment: Lab #4
In scratch lab #4 I learned about variables and how to use them in scratch. A variable is a changeable value that can equate to a number or some text. There are two types of variables: local(can be used by one sprite) and global(can be used by all sprites).
For Problem #1 I created three sprites: two buttons and a character with multiple costumes. I also made a variable named "speed." For the character I set "speed" to 0.5 and in a forever loop had that be the number of seconds in between each costume change. For the faster button I had it set "speed" to "speed-0.1" so that the time between each costume change would be shorter and the animation would look faster. For the slower button I had it set "speed" to "speed+0.1" so the time between each costume change would be longer and the animation would look slower.
For problem #2 I had a sprite ask the 4 questions and set the answer that the user inputs as a variable. When all the questions were answered I had the question sprite broadcast a message to another sprite to make it appear on the screen. The question sprite would then tell the other sprite about the user according to the answers they input.
For problem #3 I created 4 variables named x1, y1, x2, y2 just like the variables in the distance formula. I had the sprite ask the user what the variables are as they represent the coordinates they would like to find the distance between. I had each variable equal the user's answers.Then I had the sprite calculate and say the distance by putting a square root operator with the part of the distance formula that's inside the square root ((x2-x1)(x2-x1)+(y2-y1)(y2-y1))in a speech bubble block.
Are variables in computer programming the same as variables in math class? Why or why not?
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)
How many values can a variable store at one time?
What will the following code snippet do? Explain why it doesn’t work as intended.
Given the following code snippet, explain what is happening.