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 8 - More Functions


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


Clearing up Parameters

Parameters are just like variables, except they can only be seen by the function they are defined in. And the way you specify their values is different. However, they are very useful tools for making more modular programs, so clearing up any confusion is necessary.


In-class Activity 1

It's Full of Stars

In a file called star.py, create a function called draw_star that queries the user for x and y coordinates and uses turtle to draw a star, like the one below, at the coordinates specified by the user.


Weekly Emacs Awesomeness

Now that you know navigation and copy/paste, we can talk a bit more about how we can have Emacs make our lives easier.


Cleaning up return statements

Return statements seem to be very complicated, based on what we have seen thus far. However, if we put a slight spin on the matter, hopefully it will clear things up.


Lab Assignment 8

Change

In a file called change.py, create a function that takes a dollar amount (in cents) and returns the smallest number of coins (quarters, dimes, nickles, and pennies) necessary to represent the specified amount of change.

Using the function you create, compute the average number of coins necessary to represent the following number of cents:

Your program should compute the average by calling the function you created, and storing the result in a well named variable.


Submission

When you have finished, create a tar file of your lab8 directory. To submit your activity, go to cseval.roanoke.edu. You should see an available assignment called Lab Assignment 8. 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: Thu Sep 12 18:48:21 EDT 2013