Напишіть програмний код для реалізації наступної задачі:
Грицько з Сашком пішли в ліс по гриби. Сашко зібрав х1 опеньок та у1 маслят, Гриць – х2 опеньок та у2 маслят. Яких грибів більше зібрали хлопці і на скільки?

Напишіть програмний код для розв'язування наступних завдань:
Сашко з Грицем пішли на рибалку. Сашко спіймав х1 карасиків та у1 окунів, Гриць – х2 карасиків та у2 окунів. Хто з хлопців спіймав більше риби?
Грицько з Сашком забралися в сусідній сад, де росли яблука та груші. Сашко зірвав х1 яблук та у1 груш, Гриць – х2 яблук та у2 груш. Яких фруктів більше зірвали хлопці і на скільки?

Ответы

Ответ дал: asilvejstruk
2

# Collecting mushrooms

x1 = int(input("Sashko collected mushrooms: "))

u1 = int(input("Sashko collected boletus: "))

x2 = int(input("Grishko collected mushrooms: "))

u2 = int(input("Grishko collected boletus: "))

total_mushrooms = x1 + x2

total_boletus = u1 + u2

if x1 > x2:

   print("Sashko collected more mushrooms: ", x1 - x2)

elif x1 < x2:

   print("Grishko collected more mushrooms: ", x2 - x1)

else:

   print("Both collected the same amount of mushrooms")

if u1 > u2:

   print("Sashko collected more boletus: ", u1 - u2)

elif u1 < u2:

   print("Grishko collected more boletus: ", u2 - u1)

else:

   print("Both collected the same amount of boletus")

# Fishing fishing

x1 = int(input("Sashko caught carps: "))

u1 = int(input("Sashko caught perches: "))

x2 = int(input("Grishko caught carps: "))

u2 = int(input("Grishko caught perches: "))

total_carps = x1 + x2

total_perches = u1 + u2

if x1 > x2:

   print("Sashko caught more carps: ", x1 - x2)

elif x1 < x2:

   print("Grishko caught more carps: ", x2 - x1)

else:

   print("Both caught the same amount of carps")

if u1 > u2:

   print("Sashko caught more perches: ", u1 - u2)

elif u1 < u2:

   print("Grishko caught more perches: ", u2 - u1)

else:

   print("Both caught the same amount of perches")

# Collecting apples and pears

x1 = int(input("Sashko collected apples: "))

u1 = int(input("Sashko collected pears: "))

x2 = int(input("Grishko collected apples: "))

u2 = int(input("Grishko collected pears: "))

total_apples = x1 + x2

total_pears = u1 + u2

if x1 > x2:

   print("Sashko collected more apples: ", x1 - x2)

elif x1 < x2:

   print("Grishko collected more apples: ", x2 - x1)

else:

   print("Both collected the same amount of apples")

if u1 > u2:

   print("Sashko collected more pears: ", u1 - u2)

elif u1 < u2:

   print("Grishko collected more pears: ", u2 - u1)

else:

   print("Both collected the same amount of pears")

Вас заинтересует