CLASS CREATION #4
Tuesday, October 16
Today you will write a Python
program that asks the user to enter a word
having a certain number of letters, then
prints out a word search with this word hidden
somewhere within. A sample output is
shown below for the word FUDGE.
Follow the guidelines beneath the sample as
you write your code. I strongly
recommend that you make sure that your program
executes properly at each step before going on
to the next one!
- First decide how long you would like the
hidden word to be. (Choose any
length from four to seven letters.)
Prompt the user to enter a word with this
many letters in all capitals. Test
to make sure that the word has the right
number of letters and ask for a new word
as long as the length is not correct.
- Now decide where in the 10 by 10 grid of
letters your word will be hidden.
You must hide the word vertically, but you
may choose whether it will read up or
down. It also should not overlap
with either the first/last row or
first/last column.
- Next write a nested for loop that
creates the rows of randomly chosen
letters above
your hidden word. (In the sample
output this is the first two rows.)
Put at least two blank lines above your
word search, and tab over twice
before each row of letters.
- Then write the code that prints the rows
of letters containing the hidden
word. This could be tricky, so don't
hesitate to ask for help if needed.
All the action should take place within a
for loop of the form for j
in range (0,5):
(Change 5 to the number of letters in your
word.)
- Finally, copy and modify a previous code
block to create the rows of the word
search beneath
the hidden word. (In the sample
output this is the last three rows.) You
should end up with a neat ten by ten grid
of letters. Ask Spencer or Dr. V to
try out your word search when it is
complete.
If you need any guidance just flag down Dr.
V, Spencer, or a neighbor. Once your program
is running satisfactorily, be sure to have one
of us try out your program to certify that it
works. You are welcome to embellish your
program if you wish as described below.
OPTIONAL
If you finish early and would like to give
your professor and TA a hard time, modify the
program to make the word harder to find.
For instance, make the grid larger, or change
your alphabet so that only more common letters
appear. For a real challenge, hide your
word diagonally.
|
|