This commit is contained in:
2025-12-11 18:06:09 +05:00
parent bfa7413f9c
commit e98dd2f107
35 changed files with 0 additions and 0 deletions

28
operators_29.py Normal file
View File

@@ -0,0 +1,28 @@
n = int(input("Введите количество чисел: "))
numbers = []
for i in range(n):
num = float(input(f"Введите число {i + 1}: "))
numbers.append(num)
positive = [num for num in numbers if num > 0]
negative = []
for num in numbers:
if num < 0:
negative.append(num)
print(f"\nИсходный список: {numbers}")
print(f"Положительные числа: {positive}")
print(f"Отрицательные числа: {negative}")
if len(positive) > 0:
avg_positive = sum(positive) / len(positive)
print(f"Среднее арифметическое положительных: {avg_positive:.2f}")
if len(negative) > 0:
product = 1
for num in negative:
product *= num
geometric_mean = abs(product) ** (1 / len(negative))
print(f"Среднее геометрическое отрицательных: {geometric_mean:.2f}")