Advertisement
ALEXANDAR_GEORGIEV

coins

May 26th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. resto = float(input())
  2. list_stot = []
  3. resto_l = 0
  4. leva_1 = 0
  5. leva_2 = 0
  6. leva = int(resto)
  7. stotinki = round((resto - leva) * 100)
  8. # Ресто в левови монети
  9. leva_2 = 0
  10. leva_1 = 0
  11. stot_50 = 0
  12. stot_20 = 0
  13. stot_10 = 0
  14. stot_5 = 0
  15. stot_2 = 0
  16. stot_1 = 0
  17. if not leva:
  18.     resto_l = 0
  19. elif leva == 1:
  20.     leva_1 = 1
  21. elif leva == 2:
  22.     leva_2 = 1
  23. elif leva > 2:
  24.     if not leva % 2:
  25.         leva_2 = leva / 2    # брой монети по 2 лева и готово
  26.     elif leva // 2 > 0:
  27.         leva_2 = leva // 2
  28.         leva_1 = leva % 2
  29.  
  30. #print(f"{leva_2} монети по 2 лева и {leva_1} монети по 1 лев")
  31. # print(stotinki)
  32. stot_50 = stotinki // 50
  33. list_stot.append(stot_50)
  34. ostatak = stotinki - 50 * list_stot[0]
  35. stot_20 = ostatak // 20
  36. list_stot.append(stot_20)
  37. ostatak = ostatak - 20 * list_stot[1]
  38. stot_10 = ostatak // 10
  39. list_stot.append(stot_10)
  40. ostatak = ostatak - 10 * list_stot[2]
  41. stot_5 = ostatak // 5
  42. list_stot.append(stot_5)
  43. ostatak = ostatak - 5 * list_stot[3]
  44. stot_2 = ostatak // 2
  45. list_stot.append(stot_2)
  46. ostatak = ostatak - 2 * list_stot[4]
  47. stot_1 = ostatak
  48. list_stot.append(stot_1)
  49. #print(list_stot)
  50. # print(f"{list_stot[0]} по 50 ст, {list_stot[1]} по 20 ст, {list_stot[2]} по 10 ст, {list_stot[3]} по 5 ст, {list_stot[4]} по 2 ст, {list_stot[5]} по 1 ст")
  51. count_coin = leva_2 + leva_1 + stot_50 + stot_20 + stot_10 + stot_5 + stot_2 + stot_1
  52. print(count_coin)
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement