📖 Scenario: Imagine you are working with sound signals. Sounds are continuous in real life, but computers work with discrete samples. You want to understand how to create and compare continuous-time and discrete-time signals using Python.
🎯 Goal: You will create a continuous-time signal, sample it to get a discrete-time signal, and then visualize both signals to see the difference.
📋 What You'll Learn
Create a continuous-time signal as a dictionary with time points and values
Create a sampling rate variable
Sample the continuous signal to create a discrete signal using the sampling rate
Print the discrete signal dictionary
💡 Why This Matters
🌍 Real World
In real life, sounds and other signals are continuous, but computers process discrete samples. Sampling is how we convert continuous signals into discrete ones for digital processing.
💼 Career
Understanding continuous and discrete signals is important for jobs in audio processing, telecommunications, and any field involving digital signal processing.
Progress0 / 4 steps
1
Create a continuous-time signal
Create a dictionary called continuous_signal with these exact time-value pairs: 0.0: 0.0, 0.1: 0.59, 0.2: 0.91, 0.3: 0.95, 0.4: 0.71, 0.5: 0.24, 0.6: -0.28, 0.7: -0.68, 0.8: -0.91, 0.9: -0.99, 1.0: -0.84
Signal Processing
Hint
Use curly braces to create a dictionary with time as keys and signal values as values.
2
Set the sampling rate
Create a variable called sampling_rate and set it to 0.3 to represent the time interval between samples.
Signal Processing
Hint
Just assign the value 0.3 to the variable sampling_rate.
3
Sample the continuous signal to create a discrete signal
Create a dictionary called discrete_signal by selecting entries from continuous_signal where the time keys are multiples of sampling_rate. Use a dictionary comprehension with time and value as variables.
Signal Processing
Hint
Use a dictionary comprehension with for time, value in continuous_signal.items() and an if condition to check if time is a multiple of sampling_rate.
4
Print the discrete signal
Write a print statement to display the discrete_signal dictionary.
Signal Processing
Hint
Use print(discrete_signal) to show the sampled signal.
Practice
(1/5)
1. Which of the following best describes a continuous-time signal?
easy
A. A signal defined only at specific time points
B. A signal that is always zero
C. A signal that only takes integer values
D. A signal defined for every instant of time
Solution
Step 1: Understand continuous-time signal definition
A continuous-time signal is defined for every instant in time, meaning it varies smoothly without gaps.
Step 2: Compare with discrete-time signals
Discrete-time signals are defined only at specific time points, not continuously.
Final Answer:
A signal defined for every instant of time -> Option D
Quick Check:
Continuous-time = defined at all times [OK]
Hint: Continuous means all time points included [OK]
Common Mistakes:
Confusing continuous with discrete signals
Thinking discrete signals are continuous
Assuming continuous signals only take integer values
2. Which syntax correctly represents a discrete-time signal sampled from a continuous signal x(t) at integer times n?
easy
A. x[n] = integral of x(t)
B. x(n) = x(t) for all t
C. x[n] = x(t) at t = n
D. x(t) = x[n] for n in integers
Solution
Step 1: Identify discrete-time signal notation
Discrete-time signals use square brackets [n] to denote samples at integer times.
Step 2: Match sampling definition
Sampling means taking values of x(t) at specific times t = n, so x[n] = x(t) at t = n is correct.
Final Answer:
x[n] = x(t) at t = n -> Option C
Quick Check:
Discrete-time uses square brackets and samples at integers [OK]
Hint: Discrete signals use square brackets for indexing [OK]
Common Mistakes:
Using parentheses instead of square brackets for discrete signals
Confusing continuous and discrete notation
Thinking sampling is an integral operation
3. Given the continuous-time signal x(t) = 2t, what is the discrete-time signal x[n] sampled at integer times?
medium
A. x[n] = 2n
B. x[n] = 2t
C. x[n] = n/2
D. x[n] = 2
Solution
Step 1: Understand sampling at integer times
Sampling means replacing t by integer n in x(t).
Step 2: Substitute t = n in x(t) = 2t
We get x[n] = 2n.
Final Answer:
x[n] = 2n -> Option A
Quick Check:
Replace t with n in formula [OK]
Hint: Replace t with n for discrete samples [OK]
Common Mistakes:
Leaving t as variable in discrete signal
Dividing instead of multiplying by 2
Confusing n and t variables
4. Identify the error in this discrete-time signal definition: x[n] = x(t) at t = n + 0.5
medium
A. The notation x[n] is incorrect
B. Sampling at non-integer times is invalid for discrete-time signals
C. The signal should be continuous, not discrete
D. There is no error; this is a valid discrete-time signal
Solution
Step 1: Understand discrete-time signal sampling points
Discrete-time signals are defined at integer time points n.
Step 2: Check sampling time t = n + 0.5
Sampling at half-integers is not standard discrete-time sampling; it breaks the integer indexing rule.
Final Answer:
Sampling at non-integer times is invalid for discrete-time signals -> Option B
Quick Check:
Discrete-time = integer time samples only [OK]
Hint: Discrete-time signals sample only integer times [OK]
Common Mistakes:
Thinking discrete signals can sample at any time
Confusing notation with error
Assuming half-integers are valid discrete points
5. You have a continuous-time signal x(t) = sin(2πt). You sample it at 1 Hz (once per second). Which discrete-time signal x[n] do you get, and what is a potential problem?
hard
A. x[n] = sin(2πn); signal appears constant at zero
B. x[n] = sin(2πn); signal is perfectly captured
C. x[n] = sin(πn); signal is undersampled
D. x[n] = sin(4πn); signal is oversampled
Solution
Step 1: Write discrete-time signal from sampling
Sampling at 1 Hz means t = n seconds, so x[n] = sin(2πn).
Step 2: Evaluate sin(2πn) for integer n
Since sin(2πn) = 0 for all integers n, the sampled signal is always zero.
Step 3: Identify the problem
This is an example of aliasing where the sampled signal loses information and appears constant.
Final Answer:
x[n] = sin(2πn); signal appears constant at zero -> Option A
Quick Check:
Sampling frequency equals signal frequency causes zero samples [OK]
Hint: Sampling at signal period causes zero values [OK]
Common Mistakes:
Assuming sampling always captures signal perfectly
Ignoring aliasing effects
Confusing frequency and sampling rate
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.