Test 1 Preparation

Problem 1 (50 points):

Write a function: validDriverID that has two parameters - string of characters representing possible driver license number and string of characters representing person's last name. The function returns True if the first string is a valid driver license number in some State in USA, and False otherwise.

The rules for the valid driver license are:

  1. The general form is: XXXXX-XXXXX-XXXXX
  2. Total length is 17 characters
  3. First character of the driver license is a first letter of the person's last name. Must be upper case letter.
  4. The rest of the characters are 14 digits and 2 dashes (see the general form above)

    Examples:


    K1234-56789-12345 Kortsarts
    VALID


    A1234-12345-12345 Kortsarts
    Not Valid


    A1234567890-12345 Abba
    Not Valid


    K1234-56789-12345 kortsarts
    VALID


    k1234-56789-12345 Kortsarts
    Not Valid

    Write main to test your function.

    Problem 2 (50 points):

    Many websites offer free shipping on orders of certain amount. Write a function total_price that has 3 parameters: list of purchase amounts before shipping(integers), list of the minimal amounts to qualify for free shipping (integers), and list of shipping charges (integers). The function returns a new list with total purchase amounts including shipping.

    For example:
    price_before_ship=[100, 25, 30, 40, 50]
    ship_limit=[99, 25, 35, 45, 10]
    ship_charge=[3, 4, 10, 3, 10]

    Output:
    total_price=[100, 25,40, 43, 50]

    Use function make_list(size, min_limit, max_limit) - to randomly generate lists of integers

    Write main that asks user to enter the number of purchases. The program then randomly gerenates 3 lists of integers: list of purchase amounts before shipping, list of free shipping limits, and list of shipping charges. The program prints a new list with total purchase amounts including shipping.