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 5 - Catching Up


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


Data Types

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.


In-class Activity 1

String Operations

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.


More Emacs Awesomeness

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.


In-class Activity 2

Fahrenheit to Celsius

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.


Lab Assignment 5

Runners MPH

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.


Submission

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!


Last modified: Fri Sep 6 09:18:48 EDT 2013