Scratch Lab 2

Pair Programming

Problem #1

Problem #3

Problem #4

Questions

#1 What are the types of loops contained in Scratch? What are the differences?

There is a repeat loop, a forever loop, an if then loop, an if then else loop, and a repeat until loop.

The Repeat loop will repeat the blocks for a specified number. The forever loop repeats the blocks forever. The if then loop will activate if a specified event occurs. The if then else loop is similar, but it will stop for a specified else statement. The repeat until loop repeats until a specified event.

#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 would be the repeat until loop because you can input an event to stop the loop.

#3 Does the following loop structure work? Does it make sense? Why or why not?

No. It doesn't make sense because it is repeating "Forever and Ever!!", and "Forever loop!". It is forever times forever which makes no sense.

#4 How can sprites “know” when to begin an action? Is there more than one way?

An event is used to tell the sprite what to listen for. There are 6 different ways to do this under "Events".

#5 Are the following code snippets equivalent? Why or why not?

Yes. Else is equivalent to "if not". The "not" block before the "key pressed" block basically turns that if into an else. The spippet on the right is the inverse of the one on the left.

Click HERE to return to homepage.