Scratch Lab #7
Name: Daniel Harris
Period: 7
Assignment: Lab #7
Lab Overview
This lab focused on using define blocks in our codes. These blocks make code easier to understand, and easier to fix if something goes wrong. You can also change the blocks so that you can enter parameters into the blocks as well. Click HERE for the full description.
My Solution 1 (Problem 1)
My first challenge was to create a program that calculated the distance between two points using the define blocks. I created a block that took four parameters for the coordinates of the points, and I set them equal to the variables that were set to the input the user gave, and used them to calculate the distance using the distance formula.
Problem 1 Link
My Solution 2 (Problem 4)
The next challenge was to create a program that calculated various values from the input the user gave. I created a block that took the length and the width of a rectangle by the input the user gives. I calculated the area of the rectangle by multiplying length and width and found the side lengths of a square and triangle with the same area using their respective formulas.
Problem 3 Link
Questions
- What are two advantages to using blocks for code repetition?
- It makes the code easier to follow and if you want the chain of commands to occur in multiple locations you can just put the one block in each spot.l
- What are parameters?
- They are the values that something holds, like the values you can add to the define blocks.
- Give an example of a formula that takes at least one parameter.
- If you wanted a sprite to move 10 steps, the number 10 would be the numeric parameter you input.
- Give an example of a situation where no parameters are needed
- The show block has no parameters because there is nothing that can vary.
- Explain what you think the following program does? How do blocks make this easier to understand? Explain what you would expect within each block.
- The block tells you what is happening in the name rather than you trying to figure out what each command chain does. The get name would ask the name from the program user, the insert into list adds it to the list, the reorder list might reorder it in a particular pattern, and the continue might reset the program to get more names.