Question: PYTHON ONLY What is the problem in my code. I have completed this problem but for some reason my test runs are not coming out

PYTHON ONLY

What is the problem in my code. I have completed this problem but for some reason my test runs are not coming out as wanted. Below it shows what the runs are SUPPOSED to print but for me ALL of my test runs are coming out as eligible and im not sure why, can you help me fix this problem to get accurate test runs.

PYTHON ONLY What is the problem in my code. I have completed

this problem but for some reason my test runs are not coming

# Your solution (code written)

def isEligible(current, period, applied): if applied == "G": return True elif applied == "G1": return current == "G2" and period >= 12 elif applied == "G2": return current == "G1" and period >= 12 else: return False

# Define the listRoadTests function def listRoadTests(people, license, period, applied): results = [] for i in range(len(people)): if isEligible(license[i], period[i], applied[i]): results.append("{} is allowed to take the {} road test.".format(people[i], applied[i])) return results

TEST CASES

# Test Cases -- uncomment to run #each for-loop calls the function from part 2 and prints the elements in their resulting lists print("Test 1---") for result in listRoadTests(["John", "Arya"], ["G2", "G2"], [12, 11], ["G2", "G"]): print(result) # expected only 1 result: Arya's information print("Test 2---") for result in listRoadTests(["Claire", "Jammie"], ["G1", "G2"], [14, 26], ["G2", "G"]): print(result) # expected 2 results: Claire and Jammie's information print("Test 3---") for result in listRoadTests(["Claire", "Jammie", "John", "Arya"], ["G1", "G2", "G", "G2"], [14, 16, 18, 33], ["G2", "G", "G2","G"]): print(result) # expected only 1 result: Arya's information print("Test 4---") for result in listRoadTests(["Claire", "Jammie", "John", "Arya"], ["G1", "G2", "G1", "G2"], [14, 27, 24, 33], ["G2", "G", "G2","G"]): print(result) # expected 4 results: Claire, Jammie, John, and Arya's information

out as wanted. Below it shows what the runs are SUPPOSED to

MY TEST RUN OUTPUT

Test 1--- Arya is allowed to take the G road test. Test 2--- Claire is allowed to take the G2 road test. Jammie is allowed to take the G road test. Test 3--- Claire is allowed to take the G2 road test. Jammie is allowed to take the G road test. Arya is allowed to take the G road test. Test 4--- Claire is allowed to take the G2 road test. Jammie is allowed to take the G road test. John is allowed to take the G2 road test. Arya is allowed to take the G road test.

List the eligible drivers Write a function that determines which requests are eligible to proceed taking the road test using the function created in Part 1, and returns a list of eligible drivers information following the template below: For example, "John" with license class "G1" and 14 months experience wishes to take the "G2" road test, John's information would be included in the returning list as a string formatted to John is allowed to take the G2 road test. The returning list will only contain the information about those eligible to take the road test they applied for. Your function should: 1. Receive 4 arguments: - a list of String values with names of the drivers - a list of String values with the driver's current class - : a list of Integer values with duration in months that the person has held their current license for 1. Receive 4 arguments: - a list of String values with names of the drivers - a list of String values with the driver's current class - a list of Integer values with duration in months that the person has held their current license for - a list of String values with the class the driver is applying for 2. For each person in the list, check if they are eligible to take the road test they applied for using the isEligible function from part 1. - For a eligible drivers, you will insert their formatted information into a list (that will be returned by the function) 3. Returns a list of String values - This list will include only the information of eligible drivers using the format given in this part 2. all your arguments are lists that have respective information of a given driver at the same list position. For example, "Arya"], ["G1", "G2"], [16, 28], ["G", "G"] you can interpret that John has a G1 license for 16 months and is applying to take a G class road test; and that Arya has a G2 license for 28 months and is applying to take a G class road test. See the first test case to find out the resulting list. he given test cases will print the following: Test 1-- Arya is allowed to take the G road test. Test 2 --- Claire is allowed to take the G2 road test. Jammie is allowed to take the G road test. Test 3--- Arya is allowed to take the G road test. Test 4--- Claire is allowed to take the G2 road test. Jammie is allowed to take the G road test. John is allowed to take the G2 road test. Arya is allowed to take the G road test

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!