python_math_stat/practica/stepik/stepik_tasks/programmer_names.py
2023-10-04 16:07:27 +03:00

36 lines
1.2 KiB
Python
Raw Permalink 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.

# решение задачи с программистами
n = int(input())
if n < 20:
if n == 1:
print (str(n) + ' программист')
elif n == 2 or n == 3 or n == 4:
print (str(n) + ' программиста')
else:
print (str(n) + ' программистов')
if 19 < n < 100:
if (int(str(n)[-1]) == 2) or (int(str(n)[-1]) == 3) or (int(str(n)[-1]) == 4):
print (str(n) + ' программиста')
elif int(str(n)[-1]) == 1:
print (str(n) + ' программист')
else:
print (str(n) + ' программистов')
if n > 99:
if ((((int(str(n)[-2:])) != 12) and ((int(str(n)[-1])) == 2))) or ((((int(str(n)[-2:])) != 13) and ((int(str(n)[-1])) == 3))) or ((((int(str(n)[-2:])) != 14) and ((int(str(n)[-1])) == 4))):
print (str(n) + ' программиста')
elif (int(str(n)[-1]) == 1) and (int(str(n)[-2:]) != 11):
print (str(n) + ' программист')
else:
print (str(n) + ' программистов')
# # Короткий вариант
i=int(input())
d=i%10
h=i%100
if d==1 and h!=11:
s=""
elif 1<d<5 and not 11<h<15:
s="а"
else:
s="ов"
print(i," программист"+s)