
Зробити проекти на мові Python. Дано масив з цілих чисел. Знайти суму чисел, які більше за число
f.Знайдіть середнє арифметичне від'ємних значень елементів одновимірного масиву, всі елементи якого є дійсними числами.Допоможіть, будь ласка.

Ответы на вопрос

Отсортируй массив и подели на 2 и вот тебе среднее арифметическое
(сам программирую на C#)



Finding the sum of numbers greater than a given value in a Python array
To find the sum of numbers in an array that are greater than a given value, you can use a loop to iterate through the array and add up the numbers that meet the condition. Here's an example code snippet:
```python def sum_greater_than(array, f): total = 0 for num in array: if num > f: total += num return total ```
In this code, the `sum_greater_than` function takes two parameters: `array`, which is the input array of integers, and `f`, which is the threshold value. The function initializes a variable `total` to keep track of the sum and then iterates through each element in the array. If the element is greater than `f`, it adds it to the `total`. Finally, it returns the `total` sum.
To use this function, you can pass your array and the desired value of `f` as arguments. For example:
```python my_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] f = 5 result = sum_greater_than(my_array, f) print(result) # Output: 45 ```
In this example, the sum of numbers greater than 5 in the `my_array` is 45.
[[1]]


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili