In: Computer Science
1.)
def make_reserved_samples (original_samples):
c = len(original_samples)-1
while c >= 0:
new_samples.append(original_samples[c])
c = c - 1
return new_samples
original_samples=[1,2,3]
new_samples=[]
print(make_reserved_samples (original_samples))
2.)
def make_louder_samples(original_samples, volume):
for o in original_samples:
new_samples.append(o*volume)
return new_samples
original_samples=[1,2,3]
new_samples=[]
print(make_louder_samples(original_samples,2))
3.)
def make_reduced_samples(original_samples, skip):
new_list = []
i = 0
for a in original_samples:
if i <= len(original_samples):
new_list.append(original_samples[i])
i += skip
return new_list
original_samples=[1,2,3,4,5,6,7,8]
print(make_reduced_samples(original_samples,3))
4.)
import numpy as np
def make_clipped_samples(original_samples, clip_level):
new_list = np.clip(original_samples, a_min = - clip_level , a_max = clip_level)
return new_list
original_samples=[-5,-1,2,5,10]
print(make_clipped_samples(original_samples,4))
I have provided solution for 4 questions.Hope it helps you