Linguistic Gaming with Python

Python Practice 6

In this exercise, you practice with lists and dictionaries.


Exercise 1: Write a program that defines a list of things, for example a list of the 10 best films of all times or a list of your favorite bands/musicians.

music_list = ["Amy McDonald", "Happy Rhodes", "Joan Armatrading",
"Violent Femmes"]

  1. Modify your program so that it tells you how long your list is.
  2. The program should also print out your original list, a sorted list and a reversed sorted list.
  3. Now delete the last item from your list and print out the new list.
  4. Change your program so that the original list is printed out again after all the modifications have taken place (Hint: make a copy of the list with the "full slice" method ([:])).

Exercise 2: Work through pages 128-138 of Dawson and make sure you understand the "high scores" program.


Exercise 3: Create a program that stores a list of words plus the information of how many syllables that word has. Allow the user to look up a word and get information on how many syllables that word has. Also allow the user to find out how many words there are with a certain syllable number. For example:

Enter a number of syllables:
There are 10 words which consist of 3 syllables in our dictionary. 


Exercise 4: Take your "Battle" Program. Right now you should be able to let the user choose from a tuple of heroes and choose from a tuple of weapons. The hero should then be able to enter into several different scenarios, i.e., battle an ogre, find a chest full of things, etc. Modify your existing program in the following way:

  1. Provide the hero with an inventory list which can be changed as the game unfolds.
  2. Instead of having just one "health" value for the game, at the beginning of the game, let the user distribute 50 points among a list of attributes such as "health", "strength" and "wisdom". You should provide a default assignment and present that to the user (use a dictionary structure, of course).
  3. Design your scenarios so that sometimes it is better to be strong and sometimes it is better to be wise in order to win a battle (or gain something like a treasure).
  4. Integrate a loop which lets the user decide after each battle whether they want to play again. Also let the user decide if they want to continue with the same hero or if they want to use a different hero.
  5. Within one game setting, keep track of the scores achieved by the different heroes and print this out on user demand.

Please send the programs for Exercises 3 and 4 to aikaterini-lida at uni konstanz by 11:30 am on December 5th, 2014.

End