Writing Your Program





Navigation and directory creation

After logging into GL, navigate to the Labs directory inside your 201 folder. Create a folder there calledl lab3, and go inside the newly created lab3 directory.

linux2[1]% cd 201
linux2[2]% cd Labs
linux2[3]% pwd
/afs/umbc.edu/users/k/k/k38/home/201/Labs
linux2[4]% mkdir lab3
linux2[5]% cd lab3
linux2[6]% pwd
/afs/umbc.edu/users/k/k/k38/home/201/Labs/lab3
linux2[7]%





Creating your new program

Now you are going to write a simple Python program called milesPerWeek.py.

To open your file for editing, type

       emacs milesPerWeek.py

The first thing you should do in your new file is create and fill out the comment header block at the top of your file. Here is a template (it is text, so feel free to copy and paste it into your file):

# File:        milesPerWeek.py
# Author:      YOUR NAME
# Date:        TODAY'S DATE
# Section:     YOUR SECTION NUMBER
# E-mail:      USERNAME@umbc.edu
# Description: YOUR DESCRIPTION GOES HERE AND HERE
#              YOUR DESCRIPTION CONTINUED SOME MORE
# Collaboration: During lab, collaboration between students is allowed,
#                although I understand I still must understand the material
#                and complete the assignment myself. 





Sample output

Here is a sample run of the program, to give you an idea of what information your program should ask for, and what sort of results it should return. The process (the algorithm) you will have to figure out on your own. If you are stuck, you can check out the "Additional help" on the right for some hints.

User input is shown in blue.

linux2[7]% scl enable python33 bash
bash-4.1$ python milesPerWeek.py
How many miles do you drive each way to work?: 37
How many days do you drive to work each week?: 4
You drive 296 miles per week.
At 57 mph, you spend 5.192982456140351 hours commuting in the car each week.
bash-4.1$

Remember to enable Python3 before running your program!