Question
PLEASE FOLLOW THE REQUIREMENTS LISTED DIRECTLY BELOW. I asked this question before and they didn't follow them. Use LIST COMPREHENSION, like the problem demands. This
PLEASE FOLLOW THE REQUIREMENTS LISTED DIRECTLY BELOW. I asked this question before and they didn't follow them. Use LIST COMPREHENSION, like the problem demands. This means that the return statement should be in list comprehension format , like so: return [...]. If you find it easier, you can use dictionary comprehension whose example format is also give. Again, please follow the requirements and make sure the return statement follows list OR dictionary comprehension (dictionary preferred). Please don't do this problem if you're not sure how to solve it solely using list / dictionary comprehension
PYTHON3; DO NOT IMPORT ANY PACKAGES IMPORTANT REQUIREMENTS: - When a question requires assert statements: write assert statements to prevent any input that may corrupt your code, including arguments in invalid type, and arguments that do not fit the logic. - When a question requires list comprehension: you should not use explicit loops, including for-loop and while-loop, in this question. Instead, express the loop logic with list comprehension. FOLLOW THE REQUIREMENTS IN THE GIVEN QUESTIONS; NO CREDIT WILL BE GIVEN OTHERWISE. Write a function that finds the greatest single digit divisor (integers from 1 to 9) that each whole number from lower to upper (both integer, both inclusive) is divisible by. Return a dictionary with keys being each number from lower to upper and their values being the highest divisor. Requirements: assert statements, list comprehension Construct the returned dictionary with dictionary comprehension (will be explained in the discussion), which is a dictionary version of list comprehension. The format is: {key : value for ... in ...}. def find_greatest_divisor (lower, upper): >>> find_greatest_divisor (20, 27) {20: 5, 21: 7, 22: 2, 23: 1, 24: 8, 25: 5, 26: 2, 27: 9} >>> find_greatest_divisor(1, 10) {1: 1, 2:2, 3: 3, 4: 4, 5: 5, 6: 6, 7:7, 8: 8, 9: 9, 10: 5} >>> find_greatest_divisor (11, 19) {11: 1, 12: 6, 13: 1, 14: 7, 15: 5, 16: 8, 17: 1, 18: 9, 19: 1} >>> find_greatest_divisor (98, 25) Traceback (most recent call last): AssertionErrorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started