Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In python with explanation please. 1. Implement a function constantDiff) that takes a list of characters and an integer as parameters. The function returns True
In python with explanation please.
1. Implement a function constantDiff) that takes a list of characters and an integer as parameters. The function returns True if the difference between the encoding of each adjacent pair of characters in the list produces a value equal to the second parameter. If there is any pair of adjacent characters in the list whose encodings do not produce the second parameters as the result when they are subtracted (ignoring the sign), the function should return False. If the function is given a list with one element, an empty list, or a negative value for the difference, the function should return False. Hint: Use an indexed loop (e.g. one that directly manipulates indices using the range) function). The following shows what the function would return for several sample executions: :l/Users/bmaya/Documents/DePaul_Teaching/17-18_WQ/csc241W2017Hws/assign6.html 1/ /2018 Assignment 6- CSC 241-801 Python 3.6.2 Shell File Edit Shel Debug Options Window Help >>> constantDiff (['a', f', 'k', 'p', 5) True >>> ans = constant Diff ( [Z "X", lV' , ' T' , "R' , ' p') , 2) >>>ans True >>> constant Diff ( [ 1 , 1 , )" ] , False >>> constant Diff ( (' p') , 3) False >>>constantDiff ([],-2) False Ln: 16 Col:4Step 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