basicsPython/less-01/task-03.py
2022-02-16 19:07:47 +03:00

21 lines
924 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#3. Узнайте у пользователя число n. Найдите сумму чисел n + nn + nnn.
#Например, пользователь ввёл число 3. Считаем 3 + 33 + 333 = 369.
#
while True:
try:
one = input('введите число "n" от 0 до 9: ')
num = int(str(one))
except ValueError:
print('Это не число, попробуйте снова.')
else:
if num > 9 or num < 0: #в задании не оговариваеться сколько знаков
print('неверно') #ограничемся цифрами для наглядности и уберем отрицательные
continue
break
print('перевожу.......')
two = one+one
tree = one+one+one
print("n =",one," nn =",two," nnn =",tree)
print('Сумма чисел n + nn + nnn =',int(one)+int(two)+int(tree))