QuestionQuestion

Purpose
In this assignment you will practice with strings, conditionals and loops (for, while).
Background
In many languages, there are games that people play to make normal speech sound incomprehensible, except for a few people who are part of the game. Instead of creating a completely new language, certain sounds are added to words following rules only known to those who are playing, so that anyone else listening will hear only “gibberish” or nonsense words.
Task
We are going to create some simple rules for translating normal English into Gibberish. A common rule is to add sounds to each syllable, but since syllables are difficult to detect in a simple program, we’ll use a rule of thumb: every vowel denotes a new syllable. Since we are adding a Gibberish syllable to each syllable in the original words, we must look for the vowels.

To make things more unique, we will have two different Gibberish syllables to add. The first Gibberish syllable will be added to the first syllable in every word, and a second Gibberish syllable will be added to each additional syllable. For example, if our two Gibberish syllables were “ib” and “ag”, the word “program” would translate to “pribogragam.”

In some versions of Gibberish, the added syllable depends on the vowels in a word. For example, if we specify “*b” that means we use the vowel in the word as part of the syllable: e.g. “dog” would become “dobog” (inserting “ob” where the “*” is replaced by the vowel “o”) and “cat” would become “cabat” (inserting “ab” where “a” is used). Note that the “*” can only appear at the beginning of the syllable (to make your programming easier).
After the Gibberish syllables are specified, prompt the user for the word to translate. As you process the word, make sure you keep track of two things. First, if the current letter is a vowel, add a Gibberish syllable only if the previous letter was not also a vowel. This rule allows us to approximate syllables: translating “weird” with the Gibberish syllable “ib” should become “wibeird”, not “wibeibird”. Second, if we’ve already added a Gibberish syllable to the current word, add the secondary syllable to the remaining vowels. How can you use Booleans to handle these rules?
Finally, print the Gibberish word. Afterwards, ask the user if they want to play again, and make sure their response is an acceptable answer (“yes”/“no”, “y”/“n”). Make sure to check the validity for all of your user inputs throughout the program. Don’t let bad input create errors.
Your program will:
1. Print a message explaining the game.
2. Prompt for two Gibberish syllables (indicate the allowed wildcard character “*”).
3. Prompt for a word to translate.
4. Process the word and add the syllables where appropriate.
5. Print the final word, and ask if the user wants to play again.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

def input_syllable(syl):
    """a function that prompts user for the Gibberish syllable and checks if it is valid"""
   
    # ask user for the Gibberish syllable
    syllable = input(f"Enter your {syl} Gibberish syllable (add * for the vowel substitute): ")
   
    # keep asking for the Gibberish syllable until the user enters valid syllable
    while not all((char.isalpha() or char=="*") for char in syllable):
       syllable = input("Syllable must only contain letters or a wildcard ('*'): ")
    return syllable

while True:
    first_syl = input_syllable("first") # first Gibberish syllable
    second_syl = input_syllable("second") # second Gibberish syllable
   
    # ask user for a word to translate
    word = input("Please enter a word you want to translate:\n--> ")
    # keep asking for a word until the user enters valid word
    while not all(char.isalpha() for char in word):
       word = input("Word must only contain letters: ")


    syllables = [] # a list to store syllables
    vowels = "aeiou"
   
    # initialize counter variable
    k = 0
    # for i in 0,1 ... length(word)
    for i in range(len(word)):
       # if word[i] is a vowel and word[i-1] is not a vowel
       # then the syllable is placed between word[k] and word[i]
       if word[i].lower() in vowels and word[i-1].lower() not in vowels...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats