Assignment 1: Fun with Flags

Assigned Thursday, 25 January
Due Wednesday, 31 January, 11:59 p.m.


Getting started

  1. Open (CPO) and ensure it’s connected to your Google account.
  2. Click New File and name it asmt01.arr.

Note: We’ll grade the assignments anonymously, so please don’t include your name anywhere.


  • You’ll want to consult the Pyret documentation. It’s accessible from CPO by clicking on the pirate button. That’s Bonny, named after pirate Anne Bonny.

    In particular, we recommend at least quickly browsing through the image documentation before you start working on this assignment!

  • Your friendly coaches and instructors are also here to help with this assignment one-on-one. Check the schedule of student coaching hours and your instructor’s office hours.

Exercise 1 4 points

Flag of Switzerland

Task: Write Pyret expressions to generate the flag of Switzerland.

Exercise 2 4 points

Flag of the Republic of the Congo

Task: Write Pyret expressions to generate the flag of the Republic of the Congo.

Exercise 3 (coach-free) 4 points

Flag of Panama

Task: Write Pyret expressions to generate the flag of Panama.

Note that this is a coach-free problem. That means you’re asked to do it entirely on your own to test your understanding and ensure you’re not receiving too much help. If you really get how to put together the flags in the previous exercises, this one shouldn’t be significantly harder than what you’ve already done.


  • Take your time! If there’s something you can’t figure out, don’t panic! Show us how close you can get.
  • Try making the individual parts in the interactions pane and giving them names in the definitions pane when you’re happy with how they look.
  • Make a plan for how to combine the parts. Imagine you’re stitching the flag out of pieces of fabric. How could you do that by sewing edges together (using above and beside) or by layering the pieces of fabric on top of one another (using overlay, overlay-align, overlay-xy).

Challenge exercise (coach-free) 1 point

This is a challenge exercise, meaning that you can get an A/A− on the assignment without completing it, but you can complete it if you want a challenge or want to try for 100%. On this particular assignment, the challenge problem works out to be 7.7% of the grade, so you can get up to 92.3% without doing it.

Here’s one last flag that’s a bit trickier to draw than it may seem:

Flag of Greenland

Task: Write Pyret expressions to generate the flag of Greenland.

Grading criteria

Set up your code so that the flags are output in the interactions pane (on the right) when we press the Run button. Make sure nothing else is output (no sub-images, numbers, strings, or otherwise).

When we grade the assignments, we will be looking for accuracy in

  • the shapes that are present,
  • their general locations,
  • sizes, and
  • orientations.

We do not care about

  • exact positioning,
  • exact size ratios,
  • borders,
  • exact angles, or
  • precise color shades.

For instance, you can use "red" as the color name even if it’s a slightly different shade of red than on these flags. If you want to be more accurate, a comprehensive list of the color names Pyret understands can be found here.

For this assignment, we won’t be grading on style (but we will on future assignments!)

Submitting the assignment

  1. Download your file (FileDownload) and ensure it’s named asmt01.arr.
  2. Upload your assignment on Gradescope.

Note: You can submit as many times as you want before the deadline. Only your latest submission will be graded.