# 8 examples of 'python first digit in number' in Python

Every line of 'python first digit in number' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

## All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
``9def find_nth_digit(n):10    len = 111    count = 912    start = 113    while n > len * count:14        n -= len * count15        len += 116        count *= 1017        start *= 1018    start += (n - 1) / len19    s = str(start)20    return int(s[(n - 1) % len])``
``84def _check_digit(number):85    """Calculate a single check digit on the provided part of the number."""86    weights = (13, 15, 12, 5, 4, 17, 9, 21, 3, 7, 1)87    s = sum(w * (int(n) if n.isdigit() else alphabet.find(n) + 1)88            for w, n in zip(weights, number))89    return 'MQWERTYUIOPASDFGHJKLBZX'[s % 23]``
``110def calc_check_digit(number):111    """Calculate the extra digit that should be appended to the number to112    make it a valid number."""113    return str(_multiplication_table[checksum(str(number) + '0')].index(0))``
``19def last_digit_of_integer():20    """21    This function prints last digit of a given integer number22    """23    print("Exercise 1: Last digit of integer")24    number = int(input("Enter a number: "))2526    print("Last digit of the number is:", (number % 10))``
``71def calc_check_digit(number):72    """Calculate the check digit. The number passed should have the check73    digit included."""74    checksum = (1 - 2 * int(number[:-1], 13)) % 1175    return 'X' if checksum == 10 else str(checksum)``
``54def calc_check_digit(number):55    """Calculate the check digit for personal codes. The number passed56    should not have the check digit included."""57    # note that this algorithm has not been confirmed by an independent source58    weights = (2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9)59    check = sum(w * int(n) for w, n in zip(weights, number)) % 1160    return '1' if check == 10 else str(check)``
``48def calc_check_digit(number):49    """Calculate the check digit. The number passed should not have the50    check digit included."""51    weights = (21, 19, 17, 13, 11, 9, 7, 3, 1)52    return str(sum(w * int(n) for w, n in zip(weights, number)) % 10)``
``56def calc_check_digit(number):57    """Calculate the check digits for the number."""58    return str(sum(int(n) * (7 - i) for i, n in enumerate(number[:6])) % 10)``