Advertisement
JOHNYTHEWINNER

Coins-changed to elif/else

Mar 8th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. money = float(input())
  2. money *= 100
  3. coins = 0
  4. while money > 0:
  5.     if money >= 200:
  6.         coins += money // 200
  7.         money %= 200
  8.     elif money >= 100:
  9.         coins += money // 100
  10.         money %= 100
  11.     elif money >= 50:
  12.         coins += money // 50
  13.         money %= 50
  14.     elif money >= 20:
  15.         coins += money // 20
  16.         money %= 20
  17.     elif money >= 10:
  18.         coins += money // 10
  19.         money %= 10
  20.     elif money >= 5:
  21.         coins += money // 5
  22.         money %= 5
  23.     elif money >= 2:
  24.         coins += money // 2
  25.         money %= 2
  26.     else:
  27.         coins += money // 1
  28.         money = 0
  29.  
  30. print(f"{coins:.0f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement