Scratch Lab #2 Write Up

Name: Lexi Williams

Period: 7

Assignment: Lab #2

Lab Overview

This lab focused on loops and how to use them. I had to figure out how to repeat loops and which loops were the best to use for each problem. I also had to animate sprites and really understand all the different loops and how they work in a code.

My Solution

My solution involved creating my own sprite which is my name and making a lot of costume's for the sprite to change into when ever the commands said to. The commands I used were the "repeat" command and the "go to" command as well as the "rotation" command in order to get my name to rotate and change directions.

My Project Link

My solution for this project included remaking the loops which were given to me and deciding which one would move 100 steps. The sprites that move 100 steps are Sprite 1 repeating 10 times then moving 10 steps, Sprite 4 repeating 10 times then moving 10 steps then repeating that sequence 10 times, and Sprite 3 moving 1 step repeated 20 times then moving 5 steps repeated 16 times.

My Project Link

My solution for this project is trying to find which sprite will work the best when the code is ran and the sprite which runs foever is the one that works the best. The code is when the green flag is pressed, and the mouse pointer is touching the sprite it will say there's a mouse in my house until the mouse pointer is not touching it anymore. With the other two codes they won't work becuase they only repeat for a short amount of time and when the green flag is pressed you can't get over to the sprite quick enough for it to say there's a mouse in my house. Therefore the code with the forever loop willl work best.

My Project Link

Questions

  1. What are the types of loops contained in Scratch? What are the differences?
    • The types of loops in scratch are "repeat", "forever", and "repeat until". The differences are with "repeat" you can tell it how many times you want it to repeat. With the "forever" loop it repeats an infinite number of times until told or commanded to stop. With the "repeat until" loop the code will repeat and replay until something else is commaded of it to do or to stop.
  2. If you are given a situation where you want an action to repeat, but you don’t know how long it should repeat for, which loop is the best structure to use? Why?
    • The best loop for this situation would be the "forever" loop because if you don't know how many times it needs to repeat or when it should stop then forever would be the best option. .
  3. Does the following loop structure work? Does it make sense? Why or why not?
    • Yes the loop structure works becuase when the first "forever" occurs and says to say "forever loop" it moves into the "forever and ever" loop which keeps repeating forever and doesn't stop until commanded to.
  4. How can sprites “know” when to begin an action? Is there more than one way?
    • Sprites can know when to begin an action when either the green flag is clicked, when the space bar is pressed, when the sprite is clicked, when it is broadcasted, or when the backdrop switches. There are obviously many ways for a sprite to know when to begin an action.
  5. Are the following code snippets equivalent? Why or why not?
    • The code snippets are equivalent but the code is placed in a different way for both. There are a lot of different ways to write one code and this is an example of that.