As usual, create two directories for today's class. Create a
directory called lecture5
under activities, and
a directory called lab5
under labs.
We have been using data in this class, without really understanding what that means or why. We will clear that up a little bit today.
You might be surprised to find that we can use some of our
traditional operators on a somewhat bizarre data type,
strings. Create a file called
string_operations.py
in your lecture 5 directory. One by
one, try out the various operators using your names, as well as
integers and floating point values. Leave all of the operations that
work in your file, but comments out the ones you try but do not work.
As I said in Lecture 2, Emacs can be a very powerful text editor, once you know the tools. I will teach you some more Emacs shortcuts today.
Create a program called fahrenheit_to_celsius.py
. This
program should prompt the user for a temperature in Fahrenheit, and
print the associated value in Celsius.
For runners, race distances are often given in kilometers -- 5K, 10K, etc. A fast runner might run a 5K race in 20 minutes or so; the winning time is usually closer to 15 minutes, and most of the population comes in between 20 and 35 minutes. It's interesting to think of what these times translate to in miles per hour (MPH). In this assignment you will write a program that relates the user's race time to their speed in MPH.
Create a file called runners_mph.py
in your lab5
directory. In this file, declare variables for the race distance, the
minutes part of the runners time, and the seconds part of the runners
time. Your program should prompt the user for these values, and
convert them accordingly.
Your program can assume that the user enters in integers for all three variables. Make sure you test your code to make sure it works correctly!
Make sure to include a comment header which lists who the authors are, as well as the purpose of the file.
When you have finished, create a tar file of your lab5
directory. To submit your activity, go to cseval.roanoke.edu. You should
see an available assignment called Lab Assignment 5
. 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!