Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RUBLES = 1
- KOPS = 0
- def pluralize(value, coin_type):
- div_result = value % 10
- if div_result == 1:
- return 'рубль' if coin_type == RUBLES else 'копейка'
- if value in range(11, 20) or div_result == 0 or div_result in range(5, 10):
- return 'рублей' if coin_type == RUBLES else 'копеек'
- if div_result in range(2, 5):
- return 'рубля' if coin_type == RUBLES else 'копейки'
- def count(coins):
- rubles_val = coins // 100
- kops_val = coins % 100
- rubles = ''
- kops = ''
- if rubles_val != 0:
- rubles = str(rubles_val) + ' ' + pluralize(rubles_val, RUBLES).upper()
- print(rubles)
- if kops_val != 0:
- kops = str(kops_val) + ' ' + pluralize(kops_val, KOPS).upper()
- print(kops)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement