Loops and animations

Complete all of the problems and questions below.

Koch's ("coke") snowflake

Practice using loops with Snap! (snap.berkeley.edu/run).

  1. Press "space bar" to to clear the stage. This command can also position the arrow to a consistent spot and/or direction.
    Note: The instructor will use this command between each of the snowflake test runs.
  2. Provide the commands Koch's snowflake as defined below. Match each level to the appropriate number on the keyboard.
  3. Export command list for submission.

Special note: Must use fewer than 75 commands for snowflake levels, total! Commands counted include: move, turn, repeat, go to, move to.

Snowflake challenge (+?)

Make the loops work for you. +1 for shortest and +0.5 for second shortest total command list (as counted above). Ties will be shared.

Animated UFO with calculator

Practice using loops by animating a scene on a graphing calculator.

  1. UFOProvide the code necessary to display a UFO (see right) in the following manner:
    1. Start in the bottom left corner of the screen.
    2. Move vertically up to the center of the screen.
    3. Move horizontally to the middle of the screen.
    4. Move diagonally up and right to "fly" off the screen while getting proportionally smaller.
  2. Annotate your code by providing additional comments that explain how the commands impact the UFO animation.
  3. Run for the instructor on the due date.

Calculator challenge (+1)

After the UFO reaches the center, it rotates 180 degrees in place before flying off.

Rotation can be achieved by multiplying by the matrix, \( [[ \cos(\theta), -\sin(\theta) ][ \sin(\theta), \cos(\theta) ]] \). It may also help to know that lists can be stored as a matrices, using LIST>MATR( list1, list2, matrix-name ).

Riemann sums revisited

Use loops to create a better Riemann sum program.

  1. Provide the code for a calculator program that could be used to calculate the Riemann sum based on the following:
    Inputs Function of x
    Lower bound of x
    Upper bound of x
    Number of rectangles (N)
    Output Estimated net area based on N equally spaced rectangles using "midpoints"
  2. Include code on website with annotations that explain how the loop works.
  3. Run for the instructor on the due date.

Discussion questions

  1. What is the perimeter of the level 3 Koch snowflake? How do the commands help determine the perimeter? Please be specific.
  2. For each activity, identify the mathematics that was involved? (try to list as much as possible)


  1. Publish the assignment to your EduBlog by:
  2. By submitting the assignment, you acknowledge that all work is your own.

Loops & animation scoring guide 20 TP

Koch snowflake

  • Includes the exported command file (1 TP)
  • Keyboard keys mapped correctly (1 TP)
  • Space bar "clears" screen (1 TP)
  • At most 75 commands used total (1 TP)

____ levels are correct.

  • All (4 TP)
  • (3 TP)
  • (2 TP)
  • (1 TP)
  • No (0 TP)

UFO animation

  • Program runs correctly (2 TP)

____ commands are explained in relationship to the animation.

  • All (2 TP)
  • (1 TP)
  • None (0 TP)

Riemann sums revisited

  • Code included (1 TP)
  • First test case runs correctly (polynomial function, positive bounds, N=5, 1 TP)
  • Second test case runs correctly (polynomial function, +/- bounds, N=100, 1 TP)
  • Third test case runs correctly (trig function, +/- bounds in Radians, N=10, 1 TP)

Programming loop(s) is _____ explained.

  • fully (2 TP)
  • (1 TP)
  • not (0 TP)

Discussion questions

  • Accurate perimeter and discussion relates code to answer (1 TP)
  • Identifies at least two mathematics ideas for each activity (1 TP)



  • Shortest total program (+1 TP)
  • 2nd shortest total program (+0.5 TP)


  • Ship also rotates 180 degrees (+1 TP)

Points: 0