Odpowiedź:
Zad 1
for i in range(1, 101):
print(f"{i}. Dzień dobry")
zad2
def sum_numbers():
sum = 0
for i in range(5):
num = int(input("Podaj liczbę: "))
sum += num
return sum
result = sum_numbers()
print("Suma wprowadzonych liczb wynosi:", result)
zad3
def average_grades():
total = 0
count = 0
grade = 0
num_grades = int(input("Podaj liczbę ocen do wprowadzenia: "))
for i in range(num_grades):
grade = int(input(f"Podaj {i+1} ocenę: "))
total += grade
count += 1
if count == 0:
return 0
else:
return total / count
avg = average_grades()
print("Średnia ocen wynosi:", avg)
zad4
def print_christmas_tree(height):
for i in range(1, height + 1):
spaces = " " * (height - i)
stars = "*" * (2 * i - 1)
print(spaces + stars)
tree_height = int(input("Podaj wysokość choinki: "))
print_christmas_tree(tree_height)
zad5
def room_area(width, length):
return width * length
def total_area():
room_count = int(input("Podaj liczbę pokoi: "))
for i in range(room_count):
width = float(input(f"Podaj szerokość {i + 1} pokoju: "))
length = float(input(f"Podaj długość {i + 1} pokoju: "))
total += room_area(width, length)
return total
area = total_area()
print("Pole powierzchni domu wynosi:", area, "m^2")
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Odpowiedź:
Zad 1
for i in range(1, 101):
print(f"{i}. Dzień dobry")
zad2
def sum_numbers():
sum = 0
for i in range(5):
num = int(input("Podaj liczbę: "))
sum += num
return sum
result = sum_numbers()
print("Suma wprowadzonych liczb wynosi:", result)
zad3
def average_grades():
total = 0
count = 0
grade = 0
num_grades = int(input("Podaj liczbę ocen do wprowadzenia: "))
for i in range(num_grades):
grade = int(input(f"Podaj {i+1} ocenę: "))
total += grade
count += 1
if count == 0:
return 0
else:
return total / count
avg = average_grades()
print("Średnia ocen wynosi:", avg)
zad4
def print_christmas_tree(height):
for i in range(1, height + 1):
spaces = " " * (height - i)
stars = "*" * (2 * i - 1)
print(spaces + stars)
tree_height = int(input("Podaj wysokość choinki: "))
print_christmas_tree(tree_height)
zad5
def room_area(width, length):
return width * length
def total_area():
total = 0
room_count = int(input("Podaj liczbę pokoi: "))
for i in range(room_count):
width = float(input(f"Podaj szerokość {i + 1} pokoju: "))
length = float(input(f"Podaj długość {i + 1} pokoju: "))
total += room_area(width, length)
return total
area = total_area()
print("Pole powierzchni domu wynosi:", area, "m^2")