Ответ:
def find_purchase_combination(pencil_cost, notebook_cost, total_cost):
for pencils in range(total_cost // pencil_cost + 1):
for notebooks in range(total_cost // notebook_cost + 1):
if pencils * pencil_cost + notebooks * notebook_cost == total_cost:
return pencils, notebooks
return None
pencil_cost = 6
notebook_cost = 5
total_cost = 68
result = find_purchase_combination(pencil_cost, notebook_cost, total_cost)
if result:
pencils, notebooks = result
print(f"Кількість олівців: {pencils}")
print(f"Кількість зошитів: {notebooks}")
else:
print("Не знайдено комбінації покупок, яка задовольняє умови.")
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
def find_purchase_combination(pencil_cost, notebook_cost, total_cost):
for pencils in range(total_cost // pencil_cost + 1):
for notebooks in range(total_cost // notebook_cost + 1):
if pencils * pencil_cost + notebooks * notebook_cost == total_cost:
return pencils, notebooks
return None
pencil_cost = 6
notebook_cost = 5
total_cost = 68
result = find_purchase_combination(pencil_cost, notebook_cost, total_cost)
if result:
pencils, notebooks = result
print(f"Кількість олівців: {pencils}")
print(f"Кількість зошитів: {notebooks}")
else:
print("Не знайдено комбінації покупок, яка задовольняє умови.")
Объяснение: