Advertisement
go6odn28

While_exercises_coins

Oct 1st, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | Source Code | 0 0
  1. # 5 Coins
  2.  
  3. change = float(input())
  4. coins_counter = 0
  5.  
  6.  
  7. while change > 0:
  8.     if change >= 2:
  9.         change -= 2
  10.     elif change >= 1:
  11.         change -= 1
  12.     elif change >= 0.50:
  13.         change -= 0.50
  14.     elif change >= 0.20:
  15.         change -= 0.20
  16.     elif change >= 0.10:
  17.         change -= 0.10
  18.     elif change >= 0.05:
  19.         change -= 0.05
  20.     elif change >= 0.02:
  21.         change -= 0.02
  22.     elif change >= 0.01:
  23.         change -= 0.01
  24.  
  25.     change = round(change, 2)
  26.     coins_counter += 1
  27.  
  28. print(coins_counter)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement