Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. # MIT License
  5. #
  6. # Copyright (c) 2016 Israel Bermudez
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"), to deal
  10. # in the Software without restriction, including without limitation the rights
  11. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. # copies of the Software, and to permit persons to whom the Software is
  13. # furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in all
  16. # copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. # SOFTWARE.
  25.  
  26. import sys
  27. import getopt
  28. from math import ceil
  29.  
  30. STD_MULTS = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]
  31.  
  32. in_bol = input("BOL Number: ")
  33.  
  34. if len(in_bol) != 16:
  35. print("BOL number must have 16 Characters!\n")
  36. else:
  37. BOL = list(map(int, in_bol))
  38.  
  39. print(BOL)
  40. print(str(len(BOL)))
  41.  
  42. mul = list()
  43. n_sum = 0
  44.  
  45. for i in range(16):
  46. mul.append(BOL[i] * STD_MULTS[i])
  47. n_sum += mul[i]
  48.  
  49. check_digit = ((ceil(n_sum / 10.0)*10) - n_sum)
  50.  
  51. print(check_digit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement