As usual, create a directory to hold today's files. All programs that you write today should be stored in this directory.
$ cd ~/cs120/labs $ mkdir lab10 $ cd lab10
For review for Monday, answer the following programming questions:
print_name(name, times)
which
prints your name the specified number of times.
sum_powers(n)
, which
computes the sum of the numbers in the set:
compute_product(n)
, which
computes the series:
Since we have a test on Monday, lets do a little bit of a fun activity. One of the badges of honor for the CS major comes from the CS120 class: drawing a fish. This activity was originally created by Dr. N. Jane Ingram and Dr. Adrienne Bloss for their Java labs in the 2000's. We are keeping their tradition alive today.
Create a function draw_fish_at(x, y)
in a file
called fish.py. This function takes two integers as
parameters, which is the location on the turtle window to draw a
line drawing of a fish. Your fish should be drawn centered on the
specified coordinate.
Start on paper first!. The activity will progress much easier for you if you figure out the coordinates of various points before you begin coding. Start with a plan and your code will come together very quickly.
Make sure to test your function by calling the function multiple times with different parameters. Make sure your code follows the course's code conventions.
While this looks very complicated, it's just two partial circles and three lines. You just need to figure out the locations of certain points before you get started. Consider the following image if you need assistance:
Where the fish is 3 × r pixels wide from tail to the tip of the head.
What do you call a fish with no eyes? FSH! Add eyes to your fish so it won't accidentally swim into a dam!