# You should add your functions to the top of this file # # Figure out how 'main' and 'isCorrect' work! # # Note that main programs are provided, "main" and "main1". The first # is long but understandable at this point. The second is more clever. # You may use either one. def isCorrect(original,myAns,correctAnswer): '''Prints a message about the correctness of the answer; returns True if the answer is correct, and False otherwise ''' print(original,"-->",correctAnswer,end="") if myAns == correctAnswer: print(" YUP!") return True else: print(" WRONG: your answer is",myAns) return False def main(): # First, let's test our code allCorrect = True st = "My friend is a pig" ans = isCorrect(st,transSent(st),"yMay iendfray isay ayay igpay.") allCorrect = allCorrect and ans st = "The boss is coming" ans = isCorrect(st,transSent(st),"eThay ossbay isay omingcay.") allCorrect = allCorrect and ans st = "Iaaa" ans = isCorrect(st,transSent(st),"Iaaayay.") allCorrect = allCorrect and ans st = "I" ans = isCorrect(st,transSent(st),"Iyay.") allCorrect = allCorrect and ans st = "" ans = isCorrect(st,transSent(st),"") allCorrect = allCorrect and ans st = "Shhh He can hear us" ans = isCorrect(st,transSent(st),"Shhhay eHay ancay earhay usay.") allCorrect = allCorrect and ans if allCorrect: print("All correct! now you can input your own sentences. Enter '**' to indicate you are done") sent = input("enter an English sentence (no punctuation)\n") while sent != '**': print("Pig Latin:",transSent(sent)) sent = input("enter an English sentence (no punctuation)\n") def main1(): # First, let's test our code inputs = ["My friend is a pig","The boss is coming","Iaaa","I","","Shhh He can hear us"] outputs = ["yMay iendfray isay ayay igpay.","eThay ossbay isay omingcay.","Iaaayay.","Iyay.","","Shhhay eHay ancay earhay usay."] i = 0 allCorrect = True while i < len(inputs): ans = isCorrect(inputs[i],transSent(inputs[i]),outputs[i]) allCorrect = allCorrect and ans i += 1 if allCorrect: print("All correct! now you can input your own sentences. Enter '**' to indicate you are done") sent = input("enter an English sentence (no punctuation)\n") while sent != '**': print("Pig Latin:",transSent(sent)) sent = input("enter an English sentence (no punctuation)\n") main()