A printable PDF is available.
In-Class Practice Problems
On September 19, we will spend the lecture time solving as many BYOB programming problems as we can. This is a list of problems that we'll start going through. Any that we don't get to in class would be good practice problems to think about on your own!
Some simple math reporter blocks:
-
Make a reporter block that reports the average of two input parameters.
-
Make a reporter block that reports the absolute value of its input parameter.
-
Make a reporter block that reports an estimate of the square root of its input parameter.
Some problems with predicates:
-
Make a predicate block that reports whether the parameter is even.
-
Make a predicate block that reports whether the parameter is a prime number.
Some problems with stamping and positioning:
-
Write a script that stamps out some number of sprites, horizontally centered around the current location.
-
Turn the solution to #1 into a command block that uses a parameter for the number of copies.
Some problems with strings:
-
Make a reporter block that takes a string as a parameter and reverses the characters in the string.
-
Make a reporter block that takes a string as a parameter (ideally just containing lower-case letters) and returns the "Caesar cipher" encoding of that string, where all letters are shifted by three positions ('a' becomes 'd', 'b' becomes 'e', etc.)
Building on these problems:
-
Make a reporter block that estimates the distance between two points given in (x,y) coordinates, using your square root block from #2.
-
After stamping out the centered group of sprites, have the sprite say what the x coordinates of the stamp locations were - all locations in a single "say" block.
-
Make a reporter block that takes a string, start position, and length as parameters, and reports the indicated substring.