4. Write a program that reads a one-line sentence as input and then displays the following answer: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word "Yes". If the sentence ends with a question mark and the entry contains an odd number of characters, display the word 'No'. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, always display the words you say followed by the input string enclosed in quotation marks. Your output must be on one line. Be sure to note that in the latter case, your output must include quotes around the echoing input string. In all other cases, there are no quotes in the output. Your program doesn't have to check the input to see that the user has entered a legitimate sentence.
Respuestas a la pregunta
Contestado por
0
- See the code below, written in Python 3.X
sentence = input()
if sentence.endswith('?'):
if len(sentence) % 2 == 0:
print("Yes")
else:
print("No")
elif sentence.endswith('!'):
print("Wow")
else:
print(f'The words you say: "{sentence}"')
Adjuntos:
KHALILKAK:
hi
Otras preguntas
Matemáticas,
hace 2 meses
Matemáticas,
hace 2 meses
Castellano,
hace 2 meses
Ciencias Sociales,
hace 3 meses
Filosofía,
hace 10 meses
Matemáticas,
hace 10 meses