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 13 - Test Recap, Functions, and Drawing


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


Test Recap

Mean
67.8
Median
66.75
Maximum
95
Standard Deviation
17.67


Clearing Up - For Loops, Variables, and Accumulators (Oh my!)

I have, purposefully, been hiding some information about how for loops work. It seems that it might have been a mistake to do so. Specifically, how range operates. Hopefully, seeing how range operates will alleviate some of the confusion.


In-class Activity 1

Fibonacci Spirals

I brought up the Fibonacci Sequence in the bonus question on the test. One of the neat things about the sequence is its exceedingly simple definition. Let Fn define the nth number in the Fibonacci sequence, where F1 = 1 and F2 = 1. Then, the nth number can be computed as: Fn = Fn - 1 + Fn - 2

Create a file called fib_spiral.py in your lecture13 directory. Create a function fib, which takes a single parameter n. This function should return the nth Fibonacci number. This function should work for all n > 0.


Functions Again

or Interactive Programs – The turtle way

The only way you know how to write interactive programs thus far is by using the input function. As many of you have seen, this is quite cumbersome when your program is using turtle to display things. Wouldn't it be nicer if the user could interact with the mouse?


Lab Assignment 13

FISH....again?

Yes, we are doing fish again. You can copy your fish code from lecture 11 by executing the following commands:

cd ~/cs120/labs/lab13
cp ../lab11/fish.py .

If your previous draw_fish method did not work entirely correctly, spend some time to fix it. You can use the helpful image below as your guide: