Вопрос задан 09.12.2023 в 07:20. Предмет Информатика. Спрашивает Мокиевский Олег.

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

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

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Волков Андрей.

Отсортируй массив и подели на 2 и вот тебе среднее арифметическое

(сам программирую на C#)

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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]]

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос