Write a Python program to find the number of notes (Sample of notes: 10, 20, 50, 100, 200 and 500 )


Introduction

Write a Python program to find the number of notes (Sample of notes: 10, 20, 50, 100, 200 and 500 ). I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def no_notes(a):
  2. Q = [500, 200, 100, 50, 20, 10]
  3. x = 0
  4. for i in range(6):
  5. q = Q[i]
  6. x += int(a / q)
  7. a = int(a % q)
  8. if a > 0:
  9. x = -1
  10. return x
  11. print(no_notes(500))
  12. print(no_notes(560))

Result

python language techstudy.org

     





Related Topics




Popular Posts