0

# Hey some one solve this for me.

We have a report on the number of flu vaccinations in a class of 20 people. It has the following numbers: never: 5 once: 8 twice: 4 3 times: 3 What is the mean number of times those people have been vaccinated? Output the result using the print() statement

17 odpowiedzi

+ 5

This should help. You probably know how to gather the numbers from input so I didn't do that.
never = 5
once = 8
twice = 4
three_times = 3
def get_mean(never, once, twice, three_times):
count = never + once + twice + three_times
total = 0 * never + 1 * once + 2 * twice + 3 * three_times
return total / count
print(get_mean(never, once, twice, three_times))

+ 5

vac_nums = [0,0,0,0,0,
1,1,1,1,1,1,1,1,
2,2,2,2,
3,3,3
]
never = vac_nums.count(0)
once = vac_nums.count(1)
twice= vac_nums.count(2)
three_times = vac_nums.count(3)
mean = (never*0 + once*1 + twice*2 + three_times*3)/len(vac_nums)
print(mean)

+ 1

#your code goes here
#Write Your Dataset In This Format
ds=[0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3]
#Initialized your sum variable
sum=0
#Traverse through the dataset and add each data in the dataset to the sum variable
for i in ds:
sum+=i
#Divide the sum variable value by 20 and output the value
print(sum/20)

+ 1

@Mubeen Yasin is actually correct.

+ 1

nums={0:5,1:8,2:4,3:3}
total = 0
count = 0
for key,val in nums.items():
count += val
total += (key * val)
print(total/count)

0

Hi! You tried to do this?

0

Please tag programming language.
Supposedly you want python. You already finished 3 python courses, so you should be able to do this. At least show an attempt

0

I think numpy has a mean function built in. So assign it to a list and put numpy.mean(x)

0

try to analyze the data and hint first
dt = [0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3]
from :
never: 5
once: 8
twice: 4
3 times: 3
this is my code, I think this is the simplest way to solve this:
dt = [0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3]
dt_sum = sum(dt)
result = dt_sum/(len(dt))
print(result)

0

#CODE HERE
x=5+8+4+3
y=(0*5)+(1*8)+(2*4)+(3*3)
print(y/x)
#ENJOY 😃😃😃

0

mean = sum(vac_nums[5:]) / len(vac_nums)
print(mean)

0

sum=0;
for i in range(len(vac_nums)):
sum=sum+vac_nums[i]
print(sum/len(vac_nums))

0

mean= sum(vac_nums)/len(vac_nums)
print(mean);

0

vac_nums = [0,0,0,0,0,
1,1,1,1,1,1,1,1,
2,2,2,2,
3,3,3
]
#your code goes here
total=0
for item in vac_nums:
total+=item
average=total/len(vac_nums)
print(average)

0

vac_nums = [0,0,0,0,0,
1,1,1,1,1,1,1,1,
2,2,2,2,
3,3,3
]
#your code goes here
print(sum(vac_nums)/len(vac_nums))

- 1

Not got the answer I did the same thing

- 2

print(25/20)