As usual, create two directories for today's class. Create a
directory called lecture11
under activities, and
a directory called lab11
under labs.
Time to spin the wheel. Let's see what file you need to submit to get the other 5 points for this weeks quiz.
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.
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:
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.
prime_average
.
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.
sum_powers
, which takes as
a parameter n, and returns the sum of xx
| 0 < x < n.
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
.
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.
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!