Lab 7 Write Up

Name: Zak "The Legend" Singh

Period: 7

Assignment:Scratch Lab #7

Lab Overview

Problem 1

For Problem 1, we had to make a distance calculator using a custom block. The program would ask the coordinates for the first and second point and then tell you the distance between them.

Problem 2

In problem 2, we created a block that only accepted feet. The program would then convert the number to inches if it was smaller than a mile, or miles if it was more than a mile.

My Solution

Problem 1 Solution

For problem 1, I first defined x1, y1, x2, and y2 as variables. Then I added in the distance formula, using the variables mentioned. Then the program asks the positions of each coordinate and sets the corresponding variable to the answer.

Problem 2 Solution

For problem 2, I first defined feet as a variable. Then scratch would ask how many feet you want to enter. I then had an if/else conditional. If the answer of the previous question was over 5280, then it would convert the feet to miles and round it to a whole number. Otherwise it would convert feet to inches and round it to a whole number.

Problem 1

Problem 2

Questions

  1. What are two advantages to using blocks for code repetition?
    • It is easier to understand and fix if there is a problem.
  2. What are parameters? .
    • Parameters are value inputs within a block.
  3. Give an example of a formula that takes at least one parameter.
    • "Move 10 steps" in which the "10" is the parameter.
  4. Give an example of a situation where no parameters are needed
    • When you hide a sprite or show it, because they do not vary in any way.
  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.
    • The program adds names to list called alpha order.