After the lab, you should be proficient at
Copy /home/courses/cs111/handouts/lab6
and all of its contents, recursively, into your
labs
directory. This way, you don't have to
create the lab6
directory first. Otherwise,
you could first create the lab6
directory
and then copy all of the contents of
the /home/courses/cs111/handouts/lab6
directory (i.e., add a * to the cp command) into
your lab6
directory.
We'll practice writing several Python programs, each in their own text file.
Your programs will be graded on correctness, style, efficiency, and how well you tested them. Make sure you adhere to the good development and testing practices we discussed in class. Your code should be readable and your output should be useful and well-formatted.
After you've developed a correct solution to each program, restart IDLE or close and reopen the IDLE "shell" by running the program again (using F5), demonstrate that the program works using several good test cases, and save the output to a file named lab6.x.out, where x is the problem number.
range
function and the list constructor (in
other words, only one line of code).append
the values in a loop.Print out and label both lists.
This program reads in a phrase and produces a text shorthand. Enter a phrase: Laughing out loud Shorthand is: lol
This program reads in a phrase and produces a text shorthand. Enter a phrase: This phrase doesn't stand for anything Shorthand is: tpdsfa
data/phrases.txt
file that you
copied from the handouts
directory.
Example Output:
This program will encode a whole file using Caesar ciphers. Enter the name of a file to encode: song.txt Enter an encoder key (an integer between -25 and 25): 1 The encoded file is uijt pof hpft pvu up uif pof j mpwf uijt pof hpft pvu up uif pof j mfgu cfijoe
Doesn't that make your testing a little easier, since you don't need to type out the whole phrase every time you test?
data
directory so that you don't clutter
your lab6
directory with files.
Note: I broke up a larger problem (extending the Caesar cipher program) into multiple, smaller problems, each of which is easier to tackle than tackling the whole problem all at once. This is an important problem-solving skill to develop. You may feel like breaking the problem into smaller problems slows you down, but it usually doesn't because you spend less time debugging the smaller pieces than if you had tackled it all at once. You'll get lots of practice solving problems in this class--including on the next problem!
For each panel of judges, the lowest and highest scores are dropped (to prevent judges from biasing the results) and then averaged. The two panels are then added together for the final score. A very good score will range in the 15s and 16s.
Your task: Read in a file containing the gymnastics scores. (The file name can be a constant in your program.) The first line of the file is the average difficulty score. The remaining six lines are the judges' execution scores. (You cannot assume that the execution scores are sorted.) Calculate the average score, as described above. Display the judges' scores and the final score.
Example input file:
5.7 8.3 9.1 8.0 8.9 8.8 8.5
Example output:
Gymnastics Scores for data/scores.dat -------------------------------------------------------- Judges Execution Scores: 8.0 8.3 8.5 8.8 8.9 9.1 Average Execution Score: 8.625 Average Difficulty Score: 5.7 The Final Score: 14.325
Your output does not need to display the scores in sorted order.
Example files are data/nastia.dat
and data/shawn.dat
Break this problem into pieces (what are those pieces?) and tackle them one at a time.
turnin
directory.
(Review the UNIX handout if you don't
remember how to do that.)lab6
directory; otherwise, the
print out will be long and screwed up. You can move those files
back into your lab6
directory after you've
printed. In other words, you should only have the .py
files you wrote and the .out files you created in your directory
when you print.printLab.sh
command. You should probably print from
the labs
directory.
Print the file using the lpr
command
introduced in the first lab.
Labs are due at the beginning of Friday's class. You should
hand in the printed copy at the beginning of class, and the electronic
version should be in the turnin
directory before
1:20 p.m. on Friday.
Ask well before the deadline if you need help turning in your assignment!