CS170: Programming for the World Around Us - Graphics and Sound with Python

Activity Goals

The goals of this activity are:
  1. To use graphics and sound capabilities in Python

The Activity

Directions

Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity, and compare with your group to prepare for our whole-class discussion. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.

Model 1: Graphics

Questions

  1. Run this code in your terminal: http://www.ezgraphics.org/uploads/Software/Download/ezgraphics-2.2.tar.gz && pip install ezgraphics-2.2.tar.gz to install the ezgraphics library, and run this program. What does it do?
  2. Experiment with the functions and generate your own shapes. Can you draw a house or a stick figure? Make a function that does this, given the x and y midpoint as parameters.

Model 2: Animation

Questions

  1. Comment this program; what does it do? You will find it helpful to run the program first, and may find it helpful to set a breakpoint and use the debugger!

Model 3: Sound


Questions

  1. Save these two files into your program (call the first one sounds.py since we import sounds in the second file!) and run it.
  2. Look up DTMF tones; what is this program doing?
  3. Make a song with some tones and play the program. You might try this with the microbit to see what kinds of notes it plays when you play a melody; you can copy the frequencies into this program.

Submission

I encourage you to submit your answers to the questions (and ask your own questions!) using the Class Activity Questions discussion board. You may also respond to questions or comments made by others, or ask follow-up questions there. Answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section. You can find the link to the class notebook on the syllabus.