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.
reads=f.read().split("\n")
if reads[i] in ("yes","YES","Yes"):
reads[i]="Yes"
else: reads[i] = "No"
Зачем писать какой язык, главное скопировать.
Объяснение:
Сделано на с++
#include "pch.h"
#include "iostream"
#include "ctime"
using namespace std;
const int arr_el_count = 12;
float sr_arif;
int negative_nums_count = 0;
int arr[arr_el_count];
int main()
{
srand(time(0));
setlocale(LC_ALL, "Rus");
for (int i = 0; i < arr_el_count; i++)
arr[i] = -170 + rand() % 1000;
}
if (arr[i] < 0)
negative_nums_count++;
sr_arif += arr[i];
else if (arr[i] > 0)
arr[i] = 0;
if (negative_nums_count > 0)
sr_arif /= negative_nums_count;
cout << "Среднее арифметическое отрицательных чисел = " << sr_arif << endl;
else {
cout << "Отрицательных чисел не найдено!" << endl;
return 0;
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))
Зачем писать какой язык, главное скопировать.
Объяснение:
Сделано на с++
#include "pch.h"
#include "iostream"
#include "ctime"
using namespace std;
const int arr_el_count = 12;
float sr_arif;
int negative_nums_count = 0;
int arr[arr_el_count];
int main()
{
srand(time(0));
setlocale(LC_ALL, "Rus");
for (int i = 0; i < arr_el_count; i++)
{
arr[i] = -170 + rand() % 1000;
}
for (int i = 0; i < arr_el_count; i++)
{
if (arr[i] < 0)
{
negative_nums_count++;
sr_arif += arr[i];
}
else if (arr[i] > 0)
{
arr[i] = 0;
}
}
if (negative_nums_count > 0)
{
sr_arif /= negative_nums_count;
cout << "Среднее арифметическое отрицательных чисел = " << sr_arif << endl;
}
else {
cout << "Отрицательных чисел не найдено!" << endl;
}
return 0;
}