Question: Problem Carefully read the problem specification below:Problem SpecificationWrite a function named reverse _ arithmetic _ sequence that has three parameters, first, difference , terms. Your
ProblemCarefully read the problem specification below:Problem SpecificationWrite a function named reversearithmeticsequence that has three parameters, first,difference terms. Your code should work with data ofany datatype provided as arguments.The function should:Validate the provided parameter values see specification belowGenerate the sequence using the algorithm belowReturn the generated sequence as a list.You will need to do some validation on the parameters provided:All parameter values must be integersin either int or str format If any of the parameters do not hold integer values, the function should return None.A valid firstvalue must be between and inclusiveA valid differencevalue must be greater than and less than or equals to A valid terms value must be between and inclusiveIf any of the three restrictions above are not met, the function should return False.AlgorithmGenerate a list of numbers that begins with thefirst value. Each value in the list should be an integer datatypeEach subsequent value in the list is calculated by taking the previous value and subtracting the difference to it refer to the test cases below as examplesThenumber of items in the list should be equal to the value of terms.Skeleton Codedef reversearithmeticsequencefirstdifference,terms: Test cases: reversearithmeticsequence reversearithmeticsequence reversearithmeticsequence reversearithmeticsequence reversearithmeticsequence printreversearithmeticsequence None printreversearithmeticsequence None printreversearithmeticsequence None reversearithmeticsequence False reversearithmeticsequence False reversearithmeticsequence False reversearithmeticsequence False reversearithmeticsequence False reversearithmeticsequence False # TODO: Your code here# Call the code to run the doctestsimport doctestdoctest.testmodverboseTrue
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
