Question: Name: make _ echo _ samples Parameter ( s ) : A list of zero or more numbers, an echo offset integer, and an echo

Name: make_echo_samples
Parameter(s): A list of zero or more numbers, an echo offset integer, and an echo weight in that order. Your code can assume, and does not need to check, that the list is at least as long as the offset integer. This means that if the offset is 5, your code can assume the list has 5 or more values.
Description: Make a new list with an echo added to the list. An echo is a weakened copy of a sound delayed from bouncing off a distant object. For example, if you yell near a cliff I first hear your original sound. Then, I hear your continuing sound plus a softer copy (the echo) of your initial sound. When you stop, I only hear the softer, delayed sound of the echo. In this function the list of numbers is the original sound, the offset is the delay before the echo starts, and the echo weight is how much the echo is weakened in volume. From a problem-solving perspective, we want to create a new list using three parts:
The first values in the new list are the same as the values in the original list, from index 0 up to but not including the offset index.The values in the new list starting at the offset index and going to the length of the original list are the values from the original list plus the value offset spaces back in the original list scaled by (multiplied by) the echo weight. Convert each new number to an integer using the int conversion function.Added to the end of the new list are offset number of values copied from the end of the original list and scaled by (multiplied by) the echo weight. Convert each new number to an integer using the int conversion function.
Return: A new list with the echo added to the original list.
Example: Calling make_echo_samples([10,20,30,40],1,0.5)should return [10,25,40,55,20]. Using the three steps outlined above:
From index 0 up to but not including the offset index (1), the values in the new list are copied from the original list. In this case, that is just the value at index 0, so 10 is added to the new list.From the offset index (1) to the end of the original list length is the value from the original list plus the value offset (1) places back in the original list times the echo weight. At index 1, we have 20+ the value 1 index back times the weight: 10*0.5. So,20+(10*0.5)=25. At index 2, we have 30+ the value 1 index back times the weight: 30+(20*0.5)=40. At index 3, we have 40+(30*0.5)=55.Finally, at the end of the new list we added the offset number (1) value from the end of the original list times the weight. The last 1 item in the original list is 40, so we take that and multiply it by the weight 0.5.40*0.5=20, so 20 is added to the end of our new list.
If the offset is 2, the echo comes from 2 spots back instead of 1, and 2 values are added to the end of the new list. So calling make_echo_samples([10,20,30,40],2,0.5)would return [10,20,35,50,15,20]. Notice the list is 2 values longer as the echo lasts for 2 samples since the offset is 2(15 in the new list comes from the second to last value in the original list times the weight: 30*0.5=15, and 20 comes from the last value in the original list times the weight: 40*0.5=20). Work through both of these examples by hand to confirm you understand the process before coding.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!