Python help, please have all steps and write down comments Implement the functions below following the instruction for each problem. No template has been provided for these four problems, but I have included lots of hints. Still testing your wings. Be sure to provide an appropriate docstring for each (Note: the docstring for all four of these problems should cover more than one line) and appropriate comments. Write a function diffSequence() that takes a list of numbers (int or float) as a parameter and returns True if every trio in the list (from left to right) have the property that the difference of the first one minus the second one equals the third one. The function returns False if there is any trio in the list that does not have this property. For example, diffSequence([12, 8, 4, 4]) would return True because 12 - 8 = 4 and 8 - 4 = 4, but diffSequence([12, 8, 4, 2]) would return False because 12 - 8 = 4 but 8 - 4 != 2. If the list has fewer than three elements, the function returns False. Do not take the absolute value when computing the difference. The function must return a Boolean it does not print a value. A correct solution to this function must use an indexed loop. That is, one that makes a call to the range() function to generate indices into the list which are used to solve the problem (Review lecture notes 8-1). A solution that does not use an indexed loop will not be accepted. Note in particular that you are not allowed to use the index() or find() methods of the list class. Don’t forget to include the docstring and comments. Submissions that don’t include all will lose points. Copy and paste or screen shot the code and the seven test cases shown below in your submission. How the function should run when running these seven test cases >>> diffSequence([]) False >>> diffSequence([47]) False >>> diffSequence([54,64]) False >>> diffSequence([12,8,4,4]) True >>> diffSequence([12,8,4,2]) False >>> diffSequence([21,13,8,5,3,2,1,1]) True >>> diffSequence([20,15,5,10,5]) False
Python help, please have all steps and write down comments
Implement the functions below following the instruction for each problem. No template has been provided for these four problems, but I have included lots of hints. Still testing your wings. Be sure to provide an appropriate docstring for each (Note: the docstring for all four of these problems should cover more than one line) and appropriate comments.
Write a function diffSequence() that takes a list of numbers (int or float) as a parameter and returns True if every trio in the list (from left to right) have the property that the difference of the first one minus the second one equals the third one. The function returns False if there is any trio in the list that does not have this property. For example, diffSequence([12, 8, 4, 4]) would return True because 12 - 8 = 4 and 8 - 4 = 4, but diffSequence([12, 8, 4, 2]) would return False because 12 - 8 = 4 but 8 - 4 != 2. If the list has fewer than three elements, the function returns False. Do not take the absolute value when computing the difference. The function must return a Boolean it does not print a value. A correct solution to this function must use an indexed loop. That is, one that makes a call to the range() function to generate indices into the list which are used to solve the problem (Review lecture notes 8-1). A solution that does not use an indexed loop will not be accepted. Note in particular that you are not allowed to use the index() or find() methods of the list class. Don’t forget to include the docstring and comments. Submissions that don’t include all will lose points. Copy and paste or screen shot the code and the seven test cases shown below in your submission.
How the function should run when running these seven test cases
>>> diffSequence([])
False
>>> diffSequence([47])
False
>>> diffSequence([54,64])
False
>>> diffSequence([12,8,4,4])
True
>>> diffSequence([12,8,4,2])
False
>>> diffSequence([21,13,8,5,3,2,1,1])
True
>>> diffSequence([20,15,5,10,5])
False
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images