Linguistic Gaming with Python

Python Practice 4

In this exercise, you practice with logical operators, for-loops, indexing and slicing and in-built constants. You should read Dawson's Chapter 4 upto p. 108.

Exercise 1: Write a program that asks the user for a string that has at least 4 characters, slices off the first 3 characters of the string and then attaches these 3 characters to the end of the string. So, "python" should be returned as "honpyt", for example. If the user enters a string that has less than 4 characters, tell the user that the input is not acceptable and prompt them for another input.

Exercise 2: Write a program that asks the user for input and produces as output the string that was input minus any voiced consonants. This program can be based on Dawson's, so take a look at that.

Exercise 3: Picture a scenario where you are standing at a closed gate and are trying to enter. The gate will open for you if: a) you are Gandalf; b) you are carrying a magic wand; c) you say the right thing. Write a program that first asks the user: a) who they are; b) what they are carrying; c) what the magic word is. The program should open the gate if you are Gandalf or if you are carrying a magic wand. If neither of these situations is true, then check if the magic word contains both an "a" and the sequence "lk". For example, if the user gave "alkali" as the magic word, then the gate will open. If the user gave "aldali" or "elkuli" as magic words, then the gate will not open. You should use the "and" and "or" logical operators as described by Dawson on pp. 78-79 in this program.

Exercise 4: Write a program that takes a given word and turns it into its pig latin equivalent.

Please hand in the programs for the Exercises 1 - 3 to aikaterini-lida at uni konstanz by Friday the 21st of November by 11 am.