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.
9 def find_nth_digit(n): 10 len = 1 11 count = 9 12 start = 1 13 while n > len * count: 14 n -= len * count 15 len += 1 16 count *= 10 17 start *= 10 18 start += (n - 1) / len 19 s = str(start) 20 return int(s[(n - 1) % len])
84 def _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]
110 def calc_check_digit(number): 111 """Calculate the extra digit that should be appended to the number to 112 make it a valid number.""" 113 return str(_multiplication_table[checksum(str(number) + '0')].index(0))
19 def last_digit_of_integer(): 20 """ 21 This function prints last digit of a given integer number 22 """ 23 print("Exercise 1: Last digit of integer") 24 number = int(input("Enter a number: ")) 25 26 print("Last digit of the number is:", (number % 10))
71 def calc_check_digit(number): 72 """Calculate the check digit. The number passed should have the check 73 digit included.""" 74 checksum = (1 - 2 * int(number[:-1], 13)) % 11 75 return 'X' if checksum == 10 else str(checksum)
54 def calc_check_digit(number): 55 """Calculate the check digit for personal codes. The number passed 56 should not have the check digit included.""" 57 # note that this algorithm has not been confirmed by an independent source 58 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)) % 11 60 return '1' if check == 10 else str(check)
48 def calc_check_digit(number): 49 """Calculate the check digit. The number passed should not have the 50 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)
56 def 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)