Lab Write Up 7

Name: Cameron Beattie

Period: 7

Assignment: Lab #7

Problem Overview

This problem focused on using blocks to organise multiple smaller sections of code to create a function that converts feet to inches or miles.

My Solution

I had a sprite ask the user for a number of feet. then it took the answer and recorded it as a variable. It then went to a block to determine whether it should be converted to inches or miles. depending on which it needed to be converted to, it would convert it and then go to a new block that would tell the user the final answer.

Project Link

Problem Overview

This problem focused on using blocks to organize our code and find the distance between 2 ordered pairs.

My Solution

I had the sprite ask for 4 numbers and then set those numbers as x1, x2, y1, and y2. Then it plugged those numbers into the distance formula that I put inside a block and set the distance to the answer.

Project Link

Questions

  1. What are two advantages to using blocks for code repetition?
    • It's more organized and clean looking, and it is easy to debug. it's also just easier to implement one section of code that is used multiple times in a larger section of code.
  2. What are parameters?
    • Inputs/Variables that define a function or line of code and determines the outcome of a function.
  3. Give an example of a formula that takes at least one parameter.
    • The formula for the area of a square, the parameters are the hight and width of the square.
  4. Give an example of a situation where no parameters are needed
    • Then a something could move a set constant distance or perform an action a set amount of times
  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.
    • It takes the inputted names and orders them alphabetically. The blocks make it more organized and clean. I'd expect "get name" to record the name and then "insert into list" to put that name on a list of other names, then "reorder list" would order the entire list alphabetically and "continue" would repeat the function.