Напишітьпрограму, в якій користувач вводить значення температури в файл input.txt, і, якщо це значення менше або дорівнює 0 градусів Цельсія, необхідно вивести повідомлення A cold, isn’t it? в файл output.txt. Якщо ж температура становить більше 0 і менше 10 градусів Цельсія повідомлення в файлі буде Cool.,уінших випадках Nice weather we’re having..
input.txt:
12.5
-5
9
output.txt:
Nice weather we're having.
A cold ,isn't it?
Cool.

В файл Input.txt вводиться фраза. Напишіть програму, яка друкує Yes, якщо вводяться рядки yes або YES або Yes,у інших випадках друкує No.. Виведення здійснити в файл Output.txt.
Input.txt:
yes
YES
definitely
Output.txt:
Yes
Yes
No

Ответы

Ответ дал: tutu007
2

Ответ:

1.

with open("input.txt") as f:

  reads=list(map(float,f.read().split("\n")))

with open("output.txt", "w") as f:

  for i in range(len(reads)):

      if reads[i]<=0:

          reads[i]="A cold, is not it?"

      elif reads[i]<10:

          reads[i]="Cool."

      else:

          reads[i]="Nice weather we`re having.."

  f.write("\n".join(reads))

2.

with open("input.txt") as f:

  reads=f.read().split("\n")

with open("output.txt", "w") as f:

  for i in range(len(reads)):

      if reads[i] in ("yes","YES","Yes"):

          reads[i]="Yes"

      else: reads[i] = "No"

  f.write("\n".join(reads))

Вас заинтересует