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

  1. What are two advantages to using blocks for code repetition?
  2. What are parameters?
  3. Give an example of a formula that takes at least one parameter.
  4. Give an example of a situation where no parameters are needed
  5. Explain what you think the following program does? How do blocks make this easier to understand? Explain what you would expect within each block.