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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.