This commit is contained in:
bronku 2025-12-06 12:35:51 +01:00
parent a47ef094af
commit c516afc400
13 changed files with 240 additions and 184 deletions

View file

@ -1,29 +1,30 @@
def countdown(n):
while n > 0:
print(f"Countdown: {n}")
n -= 1
print("Blast off!")
def sum_until_negative():
total = 0
count = 0
inputs = [5, 3, 8, -1, 4, 2]
def analyze_numbers(numbers):
if not numbers:
return 0, 0, 0
for value in inputs:
if value < 0:
break
total += value
count += 1
total = sum(numbers)
average = total / len(numbers)
if count > 0:
average = total / count
return total, average
else:
return 0, 0
positive_count = 0
for num in numbers:
if num > 0:
positive_count += 1
return total, average, positive_count
print("Countdown from 5:")
countdown(5)
def get_coordinates():
x = 10
y = 20
z = 30
return x, y, z
print("\nSum until negative:")
total, avg = sum_until_negative()
print(f"Total: {total}, Average: {avg:.2f}")
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}")