Blog of Andrés Aravena
CMB2:

Class2: Quiz 1

16 February 2018. Deadline: Friday, 16 February, 17:00.

Turtle graphics

Following an ancient tradition, sprites in Scratch can draw lines when they move. You can see the options under the Pen section. The essential ones are pen down, pen up and clear. Today we are going to use them to make some nice figures.

When you finish each part please download the script to your computer and save it with file name quiz-1-part-X.sb2 and send it to me as attachments in an email. You can also share the script and send me the web link (i.e. the URL).

Triangles

You should see something like this.

Write a script that make the cat do the following movements:

  • put the cat at coordinates (0,100)
  • point in direction 90 degrees
  • clean any existing drawing
  • put the pen down
  • repeat 3 times the following
    • advance 200 steps
    • repeat 2 times
      • turn right 120 degrees
      • move 100 steps
    • repeat 2 times
      • turn left 120 degrees
      • move 100 steps
    • turn right 120 degrees
  • hide the cat

Save this script in a file named quiz-1-part-1.sb2.

Stars

Your star should be something like this.

Write a script that make the cat do the following movements:

  • put the cat at coordinates (0,150)
  • hide the cat
  • clear any existing drawing
  • put the pen down
  • point in direction 130 degrees
  • repeat 40 times
    • move 200 steps
    • turn right 130 degrees

You may want to use “Turbo Mode”, in the Edit menu. Save this script in a file named quiz-1-part-2.sb2.

Variable stars

Now we want to generalize the previous drawing. You have to create 2 variables named angle and N. They will be shown in the window.

If you click on them with the right button you can change them to slide. That allows you to change them. Please set the range of angle to minimum 70 and maximum 170. Then write a script that make the cat do the following movements:

  • put the cat at coordinates (0,-150)
  • hide the cat
  • clear any existing drawing
  • put the pen down
  • point in direction 90-(angle/2) degrees
  • repeat N times
    • move 200 steps
    • turn left angle degrees

Save this script in a file named quiz-1-part-3.sb2. Your result should look like this:

Trees of one branch

Initialization:

  • put the cat at coordinates (0,-150)
  • point in direction 0
  • clear any existing drawing
  • put the pen down

First exercise:

  • move 80 steps
  • move -80 steps

This will draw a single line and leave it in the same direction. You do not need to save this exercise.

Trees of three branches

Second exercise, after same initialization:

  • move 80 steps
  • do something
  • move -80 steps

something is:

  • rotate 30 degrees left
  • repeat 3 times
    • move 70 steps
    • move -70 steps
    • rotate 30 right
  • rotate 30 left

Trees of three branches of three branches

Your tree should look like this.

Third exercise, something is:

  • rotate 30 degrees left
  • repeat 3 times
    • move 50 steps
    • do something else
    • move -50 steps
    • rotate 30 right
  • rotate 60 left
Your homework should look like this.

here something else is:

  • rotate 30 degrees left
  • repeat 3 times
    • move 30 steps
    • move -30 steps
    • rotate 30 right
  • rotate 60 left

Save this script in a file named quiz-1-part-4.sb2.

To do at home: Generalize to N branches, turning angle every time.

Delivery

Please send me all three files in a single email to andres.aravena+cmb@istanbul.edu.tr. If you want you can also send me the links to the online projects.

Deadline: Friday, 16 February, 17:00.

Originally published at https://anaraven.bitbucket.io/blog/2018/cmb2/quiz-1.html