Lab01: Build Your Own Blocks

Due at: Thursday June 25th, 2359 hrs

Lab 1: Build Your Own Blocks

Instructions:

This worksheet serves as a guide and set of instructions to complete lab 1. All material was sourced from the CS10 version of The Beauty and Joy of Computing course.

  • You must use the starter file, found here to get credit for the lab.
  • Remember to save your work as you progress through the lab.
    • You can save your work by clicking the page icon on the upper left corner and choosing to save your work on the cloud or directly to your computer -Upper left of Snap! window with Save As...
  • Here is the workbook that you can read through for further context and additional (non-required) material.

Submitting:

  • You will need to fill in the blocks under โ€œLab 2: Build Your Own Blocksโ€ and submit this to Gradescope. Note that the titles of the files may not always match up.
  • To receive full credit, you will need to complete the required blocks, and the required blocks must pass all tests from the autograder in Gradescope.
    • For instructions on how to submit to labs to Gradescope, please see this doc.

Please note, you must use the starter file, and you must NOT edit the name of any of the required blocks. Failing to do either for these will result in the autograder failing.

Objectives:

In this lab, you will learn to create your own blocks and procedures. By the end of the lab, you will be comfortable implementing:

  • New procedures
  • Input variables
  • Loops and iteration
  • Arithmetic operations in your code (such as addition, division, subtraction, etc.)
  • Generalized procedures
  • Creating new shapes and visualizations (such as polygons, flowers, etc.)

Required Blocks:

**Please do not change the pen hue color when attempting the flower field block as it tends to mess up the autograder

Important Topics mentioned in the CS 10 Workbook:

For better understanding of the lab we highly recommend going through these workbook pages! Topics that are important but not required for this lab will be indicated with an asterisk**

Block 1: draw a polygon with (sides) sides of (length) length

Objective:

  • Create a procedure that generalizes any polygon correctly drawing the shape, with the appropriate number of sides AND turning the appropriate angle degrees
  • Your code should be able to draw any polygon (square, hexagon, octagon, etc.) on the stage

Inputs:

  • sides = number
    • This variable represents how many sides the polygon has
  • length = number
    • This variable represents how long each side is

Outputs:

  • None! It is a procedure / non-pure function, so it only displays a visual effect on the stage and does not output any values
  • What type of block did we use for this code? What type of block would report instead?

Examples:

examples of a polygon with 4 sides of 100 length
examples of a polygon with 6 sides of 100 length

Block 2: draw a square leaved flower with (leaves) leaves of (size) size

Objective:

  • Create a procedure that creates a symmetrical flower with any number of leaves. Each leaf itself is a square. So, a series of square leaves should create a flower.

Inputs:

  • leaves = number
    • A variable that represents how many leaves or petals the flower has. Remember, each leaf is square!
  • size = number
    • A variable that represents how large each leaf/square is.

Outputs:

  • None! It is a procedure / non-pure function, so it only displays a visual effect and does not output any values

Examples:
example of 'draw a square leaved flower with 6 leaves of 100 size'
example of 'draw a square leaved flower with 10 leaves of 100 size'

Submission

You may submit more than once before the deadline; only the final submission will be graded. It is your responsibility to check that the autograder on Gradescope runs as expected after you upload your submission.