Stanford Python Camp D – 8

Share:

D – 8:  Using Python Turtle module to draw animated figures

Assignment 8 – A. Rotating Rectangles

The following figure shows some sample examples of the animation. Write a program that draws a series of rectangle rotated by an increasing amount. You can use the following outline of steps to draw the animation.

  1. Set heading direction to zero
  2. Clearscreen
  3. Drawrectangle
  4. Pause 1 second
  5. Increase direction by a set amount
  6. Repeat steps B – E
Assignment 8 – A code
Assignment 8 – A outcome

Assignment 8 – B. Twinkling Stars

Write a program that draws a random placement of stars. Use random positions, random headings, and random colors to draw the stars. Use the following outline to create the animations.

  1. Set heading direction to zero
  2. Clearscreen
  3. Generate random x, y coordinates (between -300 and +300) and set position
  4. Generate random R, G, B numbers (between 0 and 255) and set color
  5. Generate random heading for direction (between 0 and 360) and set heading
  6. Draw star
  7. Pause 1 second
  8. Repeat steps B – G
Assignment 8 – B code
Assignment 8 – B outcome

Stay In Touch.

  • kimhannah2005@gmail.com