Name: Colin Yang

Period: 7

Assignment: Lab #7

Lab Overview Problem #1

This lab asked us to make a block that first takes the four parameters, and then have another block that would solve the distance between the two points given.

My Solution

My solution included a block "distance" with four different number input. Under it, the program would ask the user what the two x-coordinates and the two y-coordinates are, and set the answers as a respective variable (For example the answer to the question what's x1 would be set to variable x1). In addition, a new block "solve" needs to be created, which says the the distance formula with the four variable plugged in to the correct location. Finally, below the when flag clicked button, the "distance" block is present, with the four different varaibles placed accordingly in each space (the order of x1, y1, x2, and y2). The "solve" block is then added below the "distance" block, solving the distance between the two points that the user gives.

My Project Link

Lab Overview Problem #2

This lab asked us to get a number in feet from the user and convert it to miles if it's greater than 5280, and to inches if it is equal to or less than 5280.

My Solution

My solution involved a block that would ask the user to give the sprite a number, and two if statements. If 5279 is less than the answer, it would say the answer divided by 5280 along with the word miles. If the answer is less than 5280, it would say the answer multiplied by 12 along with the word inches.

My Project Link


1.What are two advantages to using blocks for code repetition?

Using the blocks helps us avoid having to write the same code over and over again.

2.What are parameters?

Parameters include the number input, the string input, the boolean input, and the label text for a block.

3.Give an example of a formula that takes at least one parameter.

The distance formula problem asked for a block that takes four different parameters (four number inputs).

4.Give an example of a situation where no parameters are needed

The conversion problem didn't require any parameters, as it only asked to define block "number".

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 block "alpha order" would continuously take a name, put the name into a list, reorder the list accordingly, and continue on until the variable "task complete" is equal to true. Without the blocks, the user would have to repeat the same code however many times it is necessary for "task complete" to equal true.