As usual, create two directories for today's class. Create a
directory called lecture8
under activities, and
a directory called lab8
under labs.
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 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.
Now that you know navigation and copy/paste, we can talk a bit more about how we can have Emacs make our lives easier.
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.
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.
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!