python2ruby/test/ruby/32.in
2025-12-06 12:35:51 +01:00

30 lines
No EOL
638 B
Text

def analyze_numbers(numbers):
if not numbers:
return 0, 0, 0
total = sum(numbers)
average = total / len(numbers)
positive_count = 0
for num in numbers:
if num > 0:
positive_count += 1
return total, average, positive_count
def get_coordinates():
x = 10
y = 20
z = 30
return x, y, z
data = [3, -1, 4, -2, 0, 5, -3]
total, avg, positives = analyze_numbers(data)
print(f"Numbers: {data}")
print(f"Total: {total}")
print(f"Average: {avg:.2f}")
print(f"Positive numbers: {positives}")
x, y, z = get_coordinates()
print(f"\nCoordinates: x={x}, y={y}, z={z}")