Предмет: Информатика, автор: tvoyagospoja00

Даны два натуральных числа. Напишите программу, которая определяет, в каком из них: а) больше цифр. б) сумма цифр больше. помогите пожалуйста ​

Ответы

Автор ответа: saduakasadil7
2

def res(a,b):

count,count1,sum1,sum2 = 0,0,0,0

a1 = a

b1 = b

while a > 0:

res1 = a % 10

count += 1

sum1+=res1

a//=10

while b > 0:

res2 = b % 10

count1 += 1

sum2+=res2

b//=10

if count > count1:

print(f"Количество цифр в числе {a1} > {b1}")

elif count == count1:

print(f"Количество цифр в числах {a1} и {b1} равны")

else:

print(f"Количество цифр в числе {b1} > {a1}")

if sum1 > sum2:

print(f"Сумма цифр числа {a1} больше чем сумма цифр в числе {b1}")

elif sum1 == sum2:

print(f"Сумма цифр в обоих числах {a1} и {b1} равны")

else:

print(f"Сумма цифр числа {b1} больше чем сумма цифр в числе {a1}")

return "Конец программы"

x,y=int(input()),int(input())

print(res(x,y))

Похожие вопросы
Предмет: Математика, автор: Аноним
Предмет: Английский язык, автор: Дима203324
Помогите срочно английский дам 45 БАЛЛОВ!!!
1.Adults don't let ( his / him / he / himself) go hiking alone.
2.My parents want ______ ( I/ my/ me/ mine /myself) to study hard.
3.Everyone can help wildlife by being _________(ENVIRONMENT) friendly.
4.Most of my classmates learn _________.
а)seriously
б)serious
5.Many children are ________ in sport activities and music.
а)interesting
б)interested
6.Ivan Kulibin, ___ Russians are proud of, was a great inventor.
а)which
б)how
в)because
г)who
д)whose
е)what
7.Arthur Conan Doyle, ___ character Sherlock Holmes is well-known, was born in 1859.
а)who
б)whose
в)how
г)because
д)what
е)which
8.The Tower of London _________( use) as a prison some centures ago.
9.My cousin has no problems with his friends ___ he likes to get together.
а)because
б)who
в)what
г)whose
д)which
е)how
10.She made her brother (closed / close / closes / to close) the window.
11.It seems very exciting to visit the London Tube, ___ is a modern railway system.

а)whose
б)what
в)because
г)who
д)how
е)which
12. I admire people whose _______(ACT) are brave.
13. Teachers want ( they / their / them/ themselves) to write a composition.
14. They want (our / their / us / we) to walk with them.
15. My sister wants to be an actress. She is so _______(AMBITION)
16. After he went to space in 1961 Yuri Gagarin became famous all over the world.and _________( NATION) hero.
17. I hope all the schools _______ ( open ) in September.
18. To achieve good results we have to do everything _______(PROFESSION)
19. Wales is famous for its _______natural ( BEAUTIFUL)
20. Usually sweets are (eat / eating / eaten / ate) by children.
21. New dangerous virus _______(call) COVID 19.
22. ______ a true friend is one of the most important things in our life.
а)To have
б)Having
в)Have
23.___________( ENVIROMENT) groups organise different projects to protect nature.
24. They could (hard / hardly / harder / hardlier) see an old fortress on the hill.
25. Because of water and air pollution many rare animals can _______(APPEAR).