Complete the code to define the Z-transform summation formula.
def z_transform(x, z): return sum(x[n] * (z ** (-[1])) for n in range(len(x)))
The Z-transform sums over n, raising z to the power -n.
Complete the code to calculate the Z-transform for a given sequence x and complex variable z.
def z_transform(x, z): result = 0 for n in range(len(x)): result += x[n] * ([1] ** (-n)) return result
The Z-transform formula uses z raised to the power -n.
Fix the error in the Z-transform function where the exponent is incorrect.
def z_transform(x, z): return sum(x[n] * (z ** (-[1])) for n in range(len(x)))
The exponent must be the index n, not z or other variables.
Fill both blanks to create a dictionary comprehension that maps each n to its Z-transform term.
z_terms = {n: x[n] * ([1] ** (-[2])) for n in range(len(x))}Each term is x[n] times z to the power -n.
Fill all three blanks to compute the Z-transform sum using a dictionary comprehension and sum function.
z_terms = { [1]: x[[2]] * ([3] ** (-[1])) for [1] in range(len(x)) }
result = sum(z_terms.values())The dictionary keys are n, values are x[n] times z to the -n, then sum all values.
