CPSC 121 Fall 2012 Lecture Notes: Turtle Graphics and Function Definitions, Study notes of Computer Science

These lecture notes from cpsc 121 (computer science principles) cover topics such as practicing with turtle graphics, drawing segments, and the basic layout of a python module. Students are expected to implement functions for drawing horizontal and vertical segments, as well as a main function to test their implementation.

Typology: Study notes

2012/2013

Uploaded on 09/28/2013

noob
noob 🇮🇳

4.4

(25)

105 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture Notes CPSC 121 (Fall 2012)
Today ...
More practice with Turtle
Homework
HW 2 due / HW 3 out
S. Bowers 1 of 8
pf3

Partial preview of the text

Download CPSC 121 Fall 2012 Lecture Notes: Turtle Graphics and Function Definitions and more Study notes Computer Science in PDF only on Docsity!

Today ...

  • More practice with Turtle

Homework

  • HW 2 due / HW 3 out

Exercise: Drawing Segments

In HW 3, lets say we want to draw the character ‘7’:

  1. Call the draw char 3(p, l, x, y) function
  2. This calls the draw segment a(p, l, x, y), draw segment b(p, l, x, y), and draw segment c(p, l, x, y) functions
  3. These in turn call draw horiz segment(p, l, x 1 , y 1 ), draw vert segment(p, l, x 2 , y 2 ), and draw vert segment(p, l, x 3 , y 3 )

In pairs, implement the draw horiz segment(p, l, x, y) function ...

  • Draw the “lozenge” in an imaginary rectangle with height 20 and length given by l
  • The lower left-hand corner of the rectangle is the coordinate (x, y)
  • Assume the “corners” are 10 x 10

If you finish early, implement draw vert segment(p, l, x, y)

  • with height l and width is 20

If you are done, fill your segments with a color: p.begin_fill()

draw the segment ...

p.fillcolor("gray") p.end_fill()

To complete the lab:

  • Show me that your segment works
  • Print and hand in your source file
  • Be sure your names are on the file