Scratch Lab #6
Name: Daniel Harris
Period: 7
Assignment: Lab #6
Lab Overview
This lab focused on using conditionals in coding. For example, in our pair programming assignment, we coded two ball sprites that bounced around the screen and sped up when the condition was met that they were touching each other. Also the program ended when the conditional of reaching a certain speed was met. Click HERE for the full description.
My Solution 1 (Problem 1)
My first challenge was to create a program that drew by checking for key presses within a forever loop. I created four if statements within the forever loop that checked if a key was pressed, then the sprite would move in that direction until the key was no longer being pressed. I also made another if statement that translates to "if spacebar is pressed, then go to 0, 0 and clear the pen drawing.
Problem 1 Link
My Solution 2 (Problem 2)
The next challenge was to create a program with a sprite that switched between costumes at thye rate determined by the variable speed. I created two buttons that when clicked, either doubled of halved the speed. I also created a variable called max speed that i set to 0 when the flag is clicked and used the statement, if speed>max speed, then set max speed to speed to record the fastest speed reached.
Problem 3 Link
Questions
- What is the difference between an if and and if-else statement?
- An if statement causes something to happen if a specific condition is met, an if-else also does something if the condition is specifically not being met.
- Is there a simpler way to write the following code? Explain.
- Yes, the move ten steps command can be put outside the conditional just once because it occurs in both conditions, so the conditional can be changed to an if statement.
- Which students are described by the following conditional?“if you are not a Senior and you are on the soccer team or you are in band then…”
- Freshmen, Sophmores, and Juniors who are either on the soccer team, in band or both.
- If the statement from Question 3 is changed as shown below, who else is included in the condition?
“if you are not a Senior OR you are on the soccer team or you are in band then…”
- Any student who is a senior, on the soccer team, in band, or any combination.
- Write the condition for a number being a multiple of 15. (hint: look at the block).
- Set a variable to the number that comes out of a mod block when the first number is fifteen, and if the variable is equal to zero, then say yes, it is a multiple.