Предмет: Информатика, автор: sersnevairina829

В фото должно быть: задание, блок – схема и программа.
Дан одномерный массив, введенный случайным образом. Найти:
1) произведение элементов.
2) сумму отрицательных, нечетных элементов.
3) Среднее арифметическое элементов, меньших 8

Ответы

Автор ответа: vimmortal2
0

Программа:
Python:

from random import randint

arr = [randint(-100, 100) for _ in range(20)]

proiz = 1

summMinus = summOdd = summEight = countEight = 0

for i in arr:

 proiz *= i

 if i < 0:  summMinus += i

 if i % 2 != 0:  summOdd += i

 if i < 8:

   summEight += i

   countEight += 1

print('Массив:', arr)

print('Произведение элементов:', proiz)

print('Сумма отрицательных чисел:', summMinus)

print('Сумма нечётных элементов:', summOdd)

print('Среднее арифметическое элементов, меньших 8:', summEight / countEight)

Блок-схема представлена на фото.

Объяснение:

В начале импортируем метод randint из библиотеки random. Далее массив заполняется случайными 20 числами от -100 до 100. После - регистрируются переменные: proiz = 1 (для вычисления произведения),  summMinus = summOdd = summEight = countEight = 0 (названия говорят за себя). С помощью цикла переменная i пробегается по элементам массива. Делаются проверки, которые необходимы по условию. а в конце - выводятся найденные значения в соответствии с условием. Вывод самого массива, вывод произведения всех элементов, вывод суммы отрицательных, суммы нечётных и среднего арифметического.

Результат:

Массив: [4, 85, -74, -63, -16, 30, -30, 99, -61, 27, 72, 19, 44, 97, 61, 5, 18, 29, 62, 27]

Произведение элементов: -5791336184030146257810677760000      

Сумма отрицательных чисел: -244

Сумма нечётных элементов: 325

Среднее арифметическое элементов, меньших 8: -33.57142857142857

Массив: [52, 23, -83, 46, 99, 71, 92, -99, 24, 43, -68, 4, -15, 50, -58, 72, 74, -65, -13, -40]

Произведение элементов: 642839335791815567494486425600000

Сумма отрицательных чисел: -441

Сумма нечётных элементов: -39

Среднее арифметическое элементов, меньших 8: -48.55555555555556

Приложения:
Похожие вопросы
Предмет: Английский язык, автор: fugfdyucsryigfлтм
Переведите плиз.Переводчик неправильно переводит!

It is not by chance that I entered the Agrarian University in Grodno. My parents have a small garden and we work there from spring till autumn. We grow different kinds of fruit and vegetables there. My grandparents have a lot of farm animals. I like to feed pigs, milk cows and take care of small piglets and calves. And after leaving school I didn’t hesitate about the choice of my future profession.
There are 7 faculties at our University: the Agronomical, the Plant Protection, the Biotechnological Faculties, the Faculty of Economics, the Veterinary Medicine one, the Accounting and the Engineering Technology Faculties. The University trains students to work on the farms as agronomists, stock-breedingengineers, veterinary doctors,engineers-technolo-gists, agricultural economists and accountants.
We study a lot of subjects necessary for our future work – botany, soil science, field-cropcultivation,seed-farming,selection, agrobiology, agricultural chemistry, financial planning, law, agricultural ecology, accounting. Our future work will require special professional skills to operate modern equipment. So, such subjects as informatics, biochemistry and biophysics become very important. At the tutorials and seminars we learn how to use the acquired knowledge in our future practical work. Every year we write ourcourse-papers.
Great attention is also given to the independent education and research work of the students. In the Students’ Scientific Society many of the students work on interesting theoretical and practical problems.
In order to combine correctly theoretical and practical education of the future specialists, about one-thirdof the training period is devoted to educational and training practice on the experimental farms of the University. The students placed into an atmosphere of agricultural reality master their practical skills.
After graduating from the Agrarian University students go to work to different parts of our republic. Their work will include such activities as:
–organization of crop production;
–production, financing and marketing of food products;
–working out fertilizer application systems and plant protection measures;
–increasing the total number of farm livestock;
–control of farm pollution and everyday control of livestock diseases;
–development of manufacturing processes;
–checking and improving the quality food products;
–working out new recipes;
–modifying foods to create fat-freeproducts and ready meals.
Предмет: Русский язык, автор: 1987311