from random import randint amount_init = randint(10, 200) amount_given = randint(0, amount_init) amount_left = amount_init - amount_given last = amount_init % 10 penult = amount_init // 10 % 10 word = "яблок" if last == 1 and penulte != 1: word = "яблоко" elif 2 <= last <= 4 and penult != 1: word = "яблока" sentence1 = "У Геннадия было %s %s." % (amount_init, word) last = amount_given % 10 penult = amount_given // 10 % 10 word = "яблоками" if last == 1 and penulte != 1: word = "яблоком" sentence2 = "Он поделился %s %s с Чебурашкой." % (amount_given, word) last = amount_left % 10 penult = amount_left // 10 % 10 word = "яблок" if last == 1 and penulte != 1: word = "яблоко" elif 2 <= last <= 4 and penult != 1: word = "яблока" sentence3 = "Теперь у Гены осталось всего %s %s." % (amount_left, word) print(sentence1) print(sentence2) print(sentence3)