Pls answer Question 4b - python
Part 2 A typical vehicle registration number comes in the format xxx ####y: x-prefixes #### - Numerical series (from 1 to 9999, without leading zeroes) y-Checksum The checksum letter is calculated by first converting the letters into numbers, i.e., where A=1 and Z=26, and numbers to individual digits, potentially giving six individual numbers from the registration plate. However, only two letters of the prefix are used in the checksum. For a three-letter prefix, only the last two letters are used; for a two-letter prefix, both letters are used; for a single letter prefix, the single letter corresponds to the second position, with the first position as 0. For numerals less than four digits, additional zeroes are added in front as placeholders, for example "1" is "0001". SBS 3229 would therefore give 2, 19, 3, 2, 2 and 9 (note that "S" is discarded); E 12 would give 0,5, 0, 0, 1 and 2. SS 108 would be given as 19, 19,0, 1, 0, 8. Each individual number is then multiplied by 6 fixed numbers (9, 4, 5, 4, 3, 2). These are added up, then divided by 19. The remainder corresponds to one of the 19 letters used (A, Z, Y, X, U, T, S, R, P, M, L, K, J, H, G, E, D, C, B), with "A" corresponding to a remainder of 0, "Z" corresponding to 1, "Y" corresponding to 2 and so on. In the case of SBS 3229, the final letter should be a P; for E 23, the final letter should be a H. SS 11 back letter should be a T. The letters F, I, N, O, Q, V and are not used as checksum letters.
Question 4b Define a function that meets the following specifications. Function name get_car_plate_checksum Parameter 1. str This str contains the prefixes and numerical series mentioned in the description above, without the checksum letter. There is no whitespace in between the prefixes and the numerical series 1. str Return value An uppercase letter Detailed description Compute and return the checksum from the string parameter. The computation logic is described in the section titled 'Part 2'. The checksum is one character in length. The return value is case insensitive. You should use the try and except blocks to find out is a character in a string is an integer or not. The input string may contain 1-3 letters for prefixes while there can be 1 to 4 digits for the numerical series that follows.
Pls answer Question 4b - python
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am