29 lines
917 B
Python
29 lines
917 B
Python
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}")
|