Archive for category Code Snippets

Python: Retrieve amount of weeks, days, hours and minutes

Little script to retrieve the amount of weeks, days, hours and minutes from a given integer literal:

class TimeValues(object):
def __init__(self):
amount_minutes = 0
amount_hours = 0
amount_days [...]

Tags: ,

Python: The Luhn algorithm

The Luhn algorithm or Luhn formula, is a simple formula used to validate a variety of identification numbers, such as credit card numbers. Here is my implementation written in Python:

def checkDigit(digits):
digitList = []
digitOdd = []
checksumOdd = 0
[...]

Tags: , , , ,