Unit A – Advanced Strings

Requirements

This is a two-part programming lab. First, make sure you have all of the code in string_tools.py filled in such that all the doctests pass. We will have done most of this in class. The empty template file is provided below.

Second, create a Python script named jumble.py that plays the word jumble game. Here is an example of the output:

Welcome to JUMBLE! A random animal will be selected,
and the letters jumbled all together. Try to guess
what the word is! You get three tries.

The jumbled word is *** YRNLGOFAD ***
There are 2 letters in the correct place.

Try to guess the word: DR
There are 2 letters in the correct place.

Try to guess the word: DRAGENFLY
There are 8 letters in the correct place.

Try to guess the word: DRAGONFLY
Congratulations, you won!

Here is another example:

Welcome to JUMBLE! A random animal will be selected,
and the letters jumbled all together. Try to guess
what the word is! You get three tries.

The jumbled word is *** VOROAECIRPLT ***
There are 2 letters in the correct place.

Try to guess the word: V
There are 1 letters in the correct place.

Try to guess the word: VO
There are 1 letters in the correct place.

Try to guess the word: VA
Too bad, you lost. The word was VELOCIRAPTOR!

To get the answer and jumble the word, you should do the following:

answer = string_tools.random_item(string_tools.animal_list)
jumbled = string_tools.jumble(answer)

The rest is up to you!

Submission

If you haven't already, go to https://github.com/signup/free and signup for a free GitHub account. Then, go to https://gist.github.com/ and create a Gist with the description "MSAN 501 Advanced Strings Lab" and paste in your code for both string_tools.py and jumble.py. Make sure to make the Gist private.

Once you have the Gist created, fill out the Submission form and paste the link for that Gist into the "Feedback" textbox. I'll be able to comment directly on your Gist.

SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser
ċ

View
  Aug 2, 2012, 11:32 AM Sophie Engle
ċ

Download
  7k v. 2 Aug 2, 2012, 11:35 AM Sophie Engle
Comments