In: Computer Science
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!!