Guest User

Untitled

a guest
Oct 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. Create a program that given a requested number gives you
  4. the nearest number in a list.
  5.  
  6. Considerations:
  7. - The list needs to only contain integers
  8.  
  9. This example is useful when you have only a certain number of
  10. images sizes available and you have to pick one for your station
  11. collage.
  12.  
  13. e.g.:
  14. >>> requested_size = 21
  15. >>> sizes = (1, 2, 3, 19, 29, 10, 22, 3)
  16. >>> main(requested_size, sizes)
  17. 22
  18. """
  19.  
  20. def main(requested_size, sizes):
  21. """
  22. >>> requested_size = 120
  23. >>> sizes = (33, 50, 52, 75, 100, 175, 180, 182, 200, 350)
  24. >>> main(requested_size, sizes)
  25. 100
  26. """
  27. raise NotImplementedError('Write your code here')
  28.  
  29. if __name__ == '__main__':
  30. import doctest
  31. doctest.testmod()
Add Comment
Please, Sign In to add comment