Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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