+ 1

The given array represents the daily number of infections for 30 days. The condition and output the size of the resulting array.

import numpy as np data = np.array([120, 98, 150, 65, 42, 100, 190, 220, 140, 110, 88, 89, 100, 120, 50, 180, 155, 42, 89, 77, 200, 190, 125, 98, 77, 40, 39, 59, 30, 67]) mean = np.mean(data) counter = 0 for i in data: if i>mean: counter+1 print(counter) What's wrong with my code?

20th Feb 2023, 2:45 PM
Arya Swastik Kar
Arya Swastik Kar - avatar
3 Respostas
+ 6
Arya Swastik Kar the counter will not be properly incremented currently, so it keeps the initial value of *0*. > you can use: counter += 1
23rd Feb 2023, 11:21 AM
Lothar
Lothar - avatar
+ 9
Arya Swastik Kar > what is your question ? > can you please mention the tutorial name, also the exercise number / name > we would also like to see your approach. please link your code here.
20th Feb 2023, 7:44 PM
Lothar
Lothar - avatar
+ 2
Lothar see the practice no. 10.2 of python for data science
21st Feb 2023, 3:06 AM
Arya Swastik Kar
Arya Swastik Kar - avatar