Question

In: Computer Science

Python create a program Dennis has always loved music, snd recently discovered a fascinating genre. Tautograms...

Python create a program
Dennis has always loved music, snd recently discovered a fascinating genre. Tautograms genre.
Tautograns are a special case of aliteration, which is the appearance of the same letter at the beginning of adjacent words. In particular, a sentence is a tautogram if all its word begin with the following sentences are tautograms.
French flowers bloom, San Serrano whistles softly, Pedro ordered pizza.
Dennis wants to dazzle his wife with a romantic letter full of these kinds of prayers. Help Dennus check if each sentence he wrote is tautogram or not.
Input format
Each test case is made up of a single line that contains a sentence. A sentence consists of a sequence of up to 50 words separate by individual spaces. A word is a sequence of up to 20 contiguos uppercase and lowercase letters of the English alphabet. A word contains at least one letter and a sentence contains at least test case is followed by a line containing a single character "*"

Constraints
For each test case, generate a single line that contains an uppercase " Yes " if the sentence is a tautogram, or an uppercase "No" otherwise.
Output Format
"Yes or No"

Sample input 0
Sam Serrano whistles softly
French flowers bloom
Pedro ordered Pizza
This is not tautogram
*
Sample output 0
yes
yes
yes
Not

Solutions

Expert Solution

Note: I could not understand the question properly. I am writing the program whatever I understood if it creates any problem, leave a comment.

BTW the things I didn't understand are

1. "a sentence is a tautogram if all its word begins with the following sentences are tautograms"

2. "a sentence contains at least test case is followed by a line containing a single character "*""

3. It is "Sam" or "San"

4. If the program is case sensitive how can "Pedro ordered Pizza" return yes

5. We were to generate uppercase "Yes" or "No" but in the sample output, it is in lower case.

Program:

#defining the function which will return the output
#this function will be case insensitive
def tautogram(string):
    
    #converting string to the lower case
    string = string.lower()
    
    #defining sentences that must be present
    sentences = ["french flowers bloom", "sam serrano whistles softly", "pedro ordered pizza"]
    
    #now checking whether the given condition fullfill
    for i in sentences:
        
        if i in string:
            #if present we'll return "Yes"
            return "Yes"
        
    #we'll return "No" beacause not present
    return "No"

#Main program
#remember inputs will stop if "*" given as input

#we'll store all the inputs in list and will execute after that
inputs = []

#terminating case given in if case
print("Enter strings:")
while True:
    #taking input
    string = input()

    #terminating case
    if string == "*":
        break
        
    #adding input to inputs
    inputs.append(string)
    
print("\nOutput:")
#processing output
for string in inputs:
    
    #calling function and printing output
    print(tautogram(string))

Output:

Leave a comment if you face any difficulty in code and if I need to change the code. Happy coding!!


Related Solutions

In Python Please Dennis has always loved music, and recently discovered a fascinating genre. Tautograms are...
In Python Please Dennis has always loved music, and recently discovered a fascinating genre. Tautograms are a special case of alliteration, which is the appearance of the same letter at the beginning of adjacent words. In particular, a sentence is a tautogram if all its words begin with the same letter. For example, the following sentences are tautograms. French flowers bloom, Sam Serrano whistles softly, Pedro ordered pizza. Dennis wants to dazzle his wife with a romantic letter full of...
Eleanor has always loved working with patients at a large cancer center in her city. Recently,...
Eleanor has always loved working with patients at a large cancer center in her city. Recently, however, you have noticed that the loss of one particular patient, Maria, has really been quite a blow for Eleanor. This is not the usual response Eleanor has to a patient’s death, and having worked at the center for 8 years, she has experienced her share of patient deaths. After Maria’s death, Eleanor wrote a brief post on her Facebook page saying, “Lost a...
Mary Ann has always loved to cook and is interested in starting a catering business. Being...
Mary Ann has always loved to cook and is interested in starting a catering business. Being aware of the failure rate of new businesses, she is considering buying an existing catering business that is up for sale. The current owners claim that the business is highly profitable, but Mary Ann has her doubts. She wonders why the owners would be so interested in selling the business if it is such a money maker. Furthermore, the price that they are asking...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Case study to discuss Eleanor has always loved working with patients at a large cancer center...
Case study to discuss Eleanor has always loved working with patients at a large cancer center in her city. Recently, however, you have noticed that the loss of one particular patient, Maria, has really been quite a blow for Eleanor. This is not the usual response Eleanor has to a patient’s death, and having worked at the center for 8 years, she has experienced her share of patient deaths. After Maria’s death, Eleanor wrote a brief post on her Facebook...
Case study to discuss Eleanor has always loved working with patients at a large cancer center...
Case study to discuss Eleanor has always loved working with patients at a large cancer center in her city. Recently, however, you have noticed that the loss of one particular patient, Maria, has really been quite a blow for Eleanor. This is not the usual response Eleanor has to a patient’s death, and having worked at the center for 8 years, she has experienced her share of patient deaths. After Maria’s death, Eleanor wrote a brief post on her Facebook...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
Using Python, create a program that will act as a number convertor. This program will convert...
Using Python, create a program that will act as a number convertor. This program will convert an input decimal integer into binary and hexadecimal formats. a) Define a main function named numberconvertor(). Inside the main function, write all the logic of your code. [5% marks] b) Looping indefinitely (Hint: use infinite while loop), the program should give the user the 3 options given below and allow the user to select one among them. [15% marks] 1. converting a decimal number...
Need the following program in Python: Create a program that calculates the estimated duration of a...
Need the following program in Python: Create a program that calculates the estimated duration of a trip in hours and minutes. This should include an estimated date/time of departure and an estimated date/time of arrival. Arrival Time Estimator Enter date of departure (YYYY-MM-DD): 2016-11-23 Enter time of departure (HH:MM AM/PM): 10:30 AM Enter miles: 200 Enter miles per hour: 65 Estimated travel time Hours: 3 Minutes: 5 Estimated date of arrival: 2016-11-23 Estimated time of arrival: 01:35 PM Continue? (y/n):...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT