Lab Write Up

Name: Sam Basilico

Period: 7

Assignment: Lab #7

Lab Overview

In this lab, the task was to create a block that takes one parameter, feet in converts it into miles or inches depending on whether there are more than 5280 feet.

My Solution

My solution to create a block called distance. I then made an if then statement where the if was where the answer was more than 5280 it would say that the measurment in miles is the number of feet divided by 5280. That way it would say how many miles because there are 5280 feet in a miles.

My Project Link

Lab Overview

In this problem, I had to write a program in Scratch to create a block that takes two parameters, length and width. Then it would calculate the area of the rectangle, provide the side length of a square with the same area, and then give the side length of a equilateral triangle with the same area.

My Solution

My solution to this problem was to ask a questions on the length and width and then set that to the two variables I have. Then, I set the variables to the two I had for my block. To say the area, I multiplied the width and the length. To find the side distance of the square, I found the square root the the length and width multiplied together. To find the side of the triangle, I multiplied the length and width together, found the square root of that, then idvided that by two.

My project link

Questions

  1. What are two advantages to using blocks for code repetition?
    • One advantage to using a block is to make your code more elegant with less code so it is easier to debug. Another advantage is less variables so there is more organization.
  2. What are parameters?
    • Parameters are inputs made from the block and you can put them throughout your code.
  3. Give an example of a formula that takes at least one parameter.
    • An example is converting miles to feet (miles x 5280 = feet)
  4. Give an example of a situation where no parameters are needed
    • A situation where no parameters are needed is when you need to figure out how to make a sprite move where the falg is clicked then it moves.
  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.
    • I think the program asks different peoples name and then reorders the list of names until its done. Blocks make it easier because they define certain actions. I think the gets name block asks for a name, the insert into list block inserts the name into the list, then the reorder list block takes the list and puts it in another order, then the continue block makes it go to the next task.