2025-10-28 15:22:53 +01:00

24 lines
497 B
Python

from typing import List
def product(numbers: List[float]) -> float:
"""Berechnet das Produkt aller Zahlen in einer Liste.
Args:
numbers (List[float]): Liste mit Zahlen.
Returns:
float: Das Produkt aller Zahlen.
"""
if not numbers:
raise ValueError("Liste darf nicht leer sein")
result = 1.0
for n in numbers:
result *= n
return result
# Beispieltests
print(product([1, 2, 3, 4])) # 24.0
print(product([2.5, 2, 2])) # 10.0