logo

Crowdly

Write a function rmsFunction(data,t), where data is a list of strings number...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Write a function rmsFunction(data,t), where data is a list of strings numbers, and t is a threshold. In the function, you should do the following

1) Map the data to floats.

2) Filter to keep only the  values that are greater than or equal to the threshold t. The threshold is set to 0 if not provided by the user.  If no values pass the filter, return None. 

3) Reduce the filtered numbers to compute the root-mean-square (RMS):

Test your code with the following examples:

data = ["3.5", "-2", "0", "4.0", "1.2", "5.3", "-0.7", "2.8"]

#Test 1

t = 2

print(rmsFunction(data,t))

4.0056210504739465

#Test 2

print(rmsFunction(data))

3.307063148273203

#Test 3

t = 10

print(rmsFunction(data,t))

None

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на elearn.squ.edu.om?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!