CPSC 120 B




Lecture
MWF 10:50am - 11:50am
Lab
MWF 12:00pm - 1:00pm

Scotty Smith

Office
Trexler 365-B
Office Hours
Monday / Thursday
3:00pm - 5:00pm
Email
chssmithATroanoke.edu

< Back
Printable Copy

Lecture 11 - Test Review and Drawing


As usual, create two directories for today's class. Create a directory called lecture11 under activities, and a directory called lab11 under labs.


Spin the Wheel of Destiny

Time to spin the wheel. Let's see what file you need to submit to get the other 5 points for this weeks quiz.


The Wall of Learning (Style)

So far, you have learned about proper variable names, and pre/post conditions. We have briefly talked about limiting lines to 80 characters as well. Today, we will talk more about code comments, as it pertains to what you should and should not comment.


In-class Activity 1

Test Review

Test will be Monday. Answer the questions found here.

In addition to the written portion of the test, there will be a coding portion. This will be done on the computers. For practice, attempt the following exercises, alone:

  1. Create two variables called first_name and last_name. Store your first and last name in the appropriate variables. Using one print statement, print your first and last names to the terminal.
  2. Store the average of 7,11,13,17,19,23 in a variable called prime_average.
  3. Write a function print_name, which takes as a parameter some integer, and prints your name the number of times the parameter specifies.

    Bonus: There's actually 2 ways to accomplish this. Write a function for each way.

  4. write a function sum_powers, which takes as a parameter n, and returns the sum of xx | 0 < x < n.

Drawing

Let's do something fun, since there is a test on Monday. We will cover more about drawing here, including using a new function from the turtle module called circle.


Lab Assignment 11

FISH!

Create a function called draw_fish_at in a file called fish.py. The function should draw a fish, like the one below.

The function parameters should specify the width of the fish and the location of the center of the fish. You can use the turtle module's circle function to draw the fish.

Use your new function to draw multiple fish on the turtle screen, in different locations. For bonus points, use the circle function to draw bubbles coming out of the fishes mouth.


Submission

When you have finished, create a tar file of your lab11 directory. To create a tar file, execute the following commands:

cd ~/cs120/labs
tar czf lab11.tgz lab11/

To submit your activity, go to cseval.roanoke.edu. You should see an available assignment called Lab Assignment 11. Only one of your pair should submit your activity. Make sure both partners are listed in the header of your file.

Do not forget to email your partner todays files!


Last modified: Fri Sep 20 10:07:49 EDT 2013