Go to Table of Contents

AP Computer Science Principles Performance Tasks

Explore Task

Create Task

Helpful Links for Both Performance Tasks

Showing Your Code for the AP Create Task

Snap! has two convenient ways to share some or all of your code.

Creating Script Pics

You can download a PNG image file of any block or script by right-clicking it (or control-clicking it on a mac) and selecting "script pic..." Look in your browser's Downloads folder for the image file.

If you shift-right-click (or shift-control-click) on a reporter block, you will get a script pic of the reporter with it's report bubble showing.
image of pinwheel block definition with right-click drop-down menu showing and mouse over 'script pic...' There is a balloon showing above the pointer that says, 'open a new window with a picture of this script'

Exporting All the Images at Once

You can download an HTML file of all of the blocks in your whole project as well as a picture of the stage by selecting "Export summary..." from the Snap! File menu (File button). The HTML file also land in your browser's Downloads folder. Open it (in a browser), right-click (or control-click on a mac) to copy the images you need, and paste them into the document where you are describing your code.
image of Snap! file menu open with mouse over 'Export summary...' There is a balloon showing above the pointer that says, 'open a new browser browser window with a summary of the project'

Describing Abstraction and Algorithm for the AP Create Task

You've been creating algorithms and using abstraction all year. All you need to know for the AP test is how to call attention to and describe what you've done.


In Unit 1, you created an algorithm for drawing this pinwheel shape:
image of pinwheel drawn in Snap!

the three blocks 'move (100) steps, move (-70) steps, turn clockwise (45) degrees' repeated 8 times

The shape consists of eight line segments, each the same length. The first segment is 100 steps long. To prepare for the next segment, the sprite backs up 70 steps along the first segment and turns 45 degrees to the right. Each new line segment follows the same pattern: move 100, move -70, turn 45. It could be written using eight sets of those three blocks (as shown at right). That is the algorithm, but it's hard to read. For one thing, it's hard to tell whether all the blocks are there. Using repeat makes the algorithm clearer, briefer, and easier to read. This is how the algorithm is now expressed:
repeat (8) {move (100) steps, move (-70) steps, turn clockwise (45) degrees}

Your program for the AP task will have different algorithms (stretches of code that accomplish a particular purpose), and you can point to any chunk of code like that in your program as an example of an algorithm.


The last step shown above, using repeat to clarify the structure is also a simple example of abstraction. It hides a lot of repetitive detail and shows the structure better. This type of abstraction is not what the AP Create Task is looking for though.

You used another abstraction as well. The way you actually wrote the algorithm in Unit 1 recognized that the 45° turn was \frac{1}{8} of the total turning of 360°. So you wrote the algorithm this way:
repeat (8) {move (100) steps, move (-70) steps, turn clockwise ((360) / (8)) degrees}

Changing both eights to fives in that algorithm would create a pinwheel with 5 branches. Instead of changing the numbers each time you wanted a new pinwheel, you created a block that contained the algorithm and let you just input whatever number of branches you want:
pinwheel, branches: (number of branches): {repeat(number of branches) {move (100) steps, move (-70) steps, turn clockwise (360/number of branches) degrees}}

This is the kind of example you need to show for the Create Task: a custom block used multiple times in your project. Loops are an example of abstraction, but the expectation for the Create Task is that you create and submit your own example of abstraction rather than just pointing out existing abstractions like loop blocks.

The abstraction of pinwheel helps in three ways:

  1. It saves you from having to change two numbers each time you use the code, which is prone to error (such as accidentally changing only one of them but not the other).
  2. Instead of putting all this code
    repeat (8) {move (100) steps, move (-70) steps, turn clockwise ((360) / (8)) degrees}
    in your program everywhere you want it to draw a pinwheel, you now need only
    pinwheel, branches: (8)
  3. Your code is easier for someone else to read, because it now says what it does: it makes a pinwheel with 8 branches.

When you create a block and give it a name that describes its purpose, you are creating an abstraction. You are hiding the details and showing only the purpose. When you use that pinwheel block, it shows the structure of your program more clearly. Someone reading your program doesn't need to figure out what the details inside pinwheel do; they can tell from the name that it makes a pinwheel with a given number of branches.

Note that while packing your entire program into a single block might the page cleaner, it is not a good example of abstraction. The best examples of abstraction to highlight for the AP are pieces of code that you use multiple times in your program and are clearer because they are packed into a well-named block. You can often use what's in that block as an example of the algorithm for the purpose that the block serves.