Intro to Programming with Python-- Extra Credit Challenge

This is for Intro to Programming with Python attendees, a little extra credit challenge
to keep you in the python flow of things!

We hope you enjoyed the workshop and are eager to expand your
knowledge of programming in Python. To help you do that, here is a
little challenge for you. Imagine you wrote a large program with many
functions that all draw different shapes with the turtle. Can you make
it possible to “play back” all those turtle movements with one single
function? Is there a way to “record” all movements the turtle makes to
a file that this function would then read?

There are a few steps involved to complete this task.

For recording:

  • before any turtle movements are made, open a file to which they will
    be recorded

  • whenever you called turtle.forward(), etc. in your code before,
    instead call a function that also writes this movement to the file

  • close the file after all movements have been recorded

For playing back:

  • open the file that was written during recording

  • read each line and figure out what kind of movement it is and how
    far you need to move (e.g. “forward 100”)

  • tell the turtle to carry out this movement

  • close the file

The documentation for the Python language and its’ built-in library
might be useful when working on this exercise.

For working with files:

For working with the text that you have read from a file:

Documentation for programming languages and libraries can be hard to
read, especially for beginners who don’t neccessarily know all the
jargon used. Feel free to use Google to find other resources and, of
course, ask questions in this thread.

Good luck!

if you would like assistance with this challenge, feel free to attend any of the upcoming Continuous Python Learning Group meetups. You can find out when they occur by joining our meetup page here:

also keep an eye out for the OpenTechSchool Learners Meetup. we will be talking about understanding documentation in an upcoming meetup. Stay tuned!