Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define the Z-transform summation formula.
Signal Processing
def z_transform(x, z): return sum(x[n] * (z ** (-[1])) for n in range(len(x)))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using z as the exponent instead of n
Using x as the exponent
Using a constant exponent
✗ Incorrect
The Z-transform sums over n, raising z to the power -n.
2fill in blank
mediumComplete the code to calculate the Z-transform for a given sequence x and complex variable z.
Signal Processing
def z_transform(x, z): result = 0 for n in range(len(x)): result += x[n] * ([1] ** (-n)) return result
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using x or n as the base
Using result as the base
✗ Incorrect
The Z-transform formula uses z raised to the power -n.
3fill in blank
hardFix the error in the Z-transform function where the exponent is incorrect.
Signal Processing
def z_transform(x, z): return sum(x[n] * (z ** (-[1])) for n in range(len(x)))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using z as exponent
Using x as exponent
Using a constant exponent
✗ Incorrect
The exponent must be the index n, not z or other variables.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps each n to its Z-transform term.
Signal Processing
z_terms = {n: x[n] * ([1] ** (-[2])) for n in range(len(x))} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping base and exponent
Using x as base or exponent
✗ Incorrect
Each term is x[n] times z to the power -n.
5fill in blank
hardFill all three blanks to compute the Z-transform sum using a dictionary comprehension and sum function.
Signal Processing
z_terms = { [1]: x[[2]] * ([3] ** (-[1])) for [1] in range(len(x)) }
result = sum(z_terms.values()) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using x as index
Using wrong base or exponent
✗ Incorrect
The dictionary keys are n, values are x[n] times z to the -n, then sum all values.