Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

develop python program 1. A Simple Auto-Responder (5 points) Dene a Python funct

ID: 3889487 • Letter: D

Question

develop python program

1. A Simple Auto-Responder (5 points)

Dene a Python function named getResponse() that takes a string as its only argument and returns a new string. If the argument ends with a question mark and has an even number of characters, the function should return the string "Yes". If the argument ends with a question mark and contains an odd number of characters, the function should return the string "No". If the argument ends with an exclamation point, the function should return the string "Wow". Otherwise, the function should return the string "You always say" followed by the argument.

Explanation / Answer

Hi,


def getResponse(str):
my_string=str;
length=len(my_string)
if my_string[length-1]=="?":
if (length-1)%2 == 0:
print "even "
else:
print "odd "
elif my_string[length-1]=="!":
print "Wow "
else:
print "you always say "

string=raw_input("hi ")
getResponse(string)

Sample output:

hi

hey what's app!

wow