Advertisement
go6odn28

While_exercises_5_Coins

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