After the lab, you should be proficient at
Create a subdirectory called deal_or_nodeal
. Copy all
the files from /home/courses/cs111/handouts/lab7
into the
deal_or_nodeal
directory you created.
We'll practice writing several Python programs, each in their own text file. Name the files lab7.1.py through lab7.6.py.
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 lab7.x.out, where x is the problem number.
Extra Credit: Can you make this implementation more efficient than the previous program's implementation? (Worth up to 5 pts extra credit. If you implemented something similar in the last lab, you can only earn 3 extra points.)
main
function.
Then, modify your program to include a function called
translateLetter
that takes as parameters a letter and a key
and returns the translated version of the letter. Call the
translateLetter
function in the encoding function you just wrote.
In comments, briefly compare the readablity, reusability, and efficiency of this program with the original program from last lab.
game.py
that contains some useful game variables and functions.
Constants:
Assign the constants appropriate values.
Functions:
Save rainbowdice.py as lab7.3.py and
modify it to use the game
module, i.e.,
use game
's constants and call game
's
functions.
In comments, compare the readability of rainbowdice, with and without the module.
append
the
values in a loop.
range
function.
Print out and label both lists.
This program reads in a phrase and produces a text shorthand. Enter a phrase: This phrase doesn't stand for anything Shorthand is: tpdsfa This program reads in a phrase and produces a text shorthand. Enter a phrase: Laughing out loud Shorthand is: lol
case_values.txt
or 7_million_cases.txt
(the files that you previously
copied into the directory deal_or_nodeal
). Save the
amounts in a list. (Note: what are the data types of the amounts?)
Put the code into a function called readCaseValues
that
takes the file name as a parameter and returns the list. Create an
appropriate main
function.
game
module. You can add more functions to the game
module, as
appropriate. The difficulty of the game will determine the amount of
extra credit you will receive.
Since you already have a solution for Craps, writing another solution
that uses the game
module (and adding other functions, as
appropriate) will earn you 5 extra credit points.
turnin
directory.
(Review the UNIX handout if you don't
remember how to do that.)
labs/lab7
directory. Verify that you have only the
.py files you wrote and the .out files you created in that directory
(plus a directory called deal_or_nodeal
).
printLab.sh
command to create a file to print out. 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 2:25
p.m. on Friday.
Ask well before the deadline if you need help turning in your assignment!