number of vacciens (phyton) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

number of vacciens (phyton)

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. Hint: Think about the data this way: it contains 20 values, each representing the number of vaccinations the corresponding person had.

17th Oct 2021, 8:16 AM
A.K.-GAMERZ __YT
A.K.-GAMERZ __YT - avatar
6 Answers
+ 2
A.K.-GAMERZ __YT Is your problem with the syntax of the code, the logic of the challenge, or the math required? Please attach your attempt, or further details about your problem because it looks like you want someone to solve this for you. But I am sure that is not so! 😉
17th Oct 2021, 9:49 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
complete the python for beginner course first
17th Oct 2021, 9:52 AM
Prabhas Koya
+ 2
do you need an explanation ?
17th Oct 2021, 10:27 AM
Jasy Fabiano
Jasy Fabiano - avatar
+ 1
data={"never":5,"once":8,"twice":4,"3 times":3} total=0 count=0 for key,value in data.items(): if key=="never": continue else: count+=1 total+=data[key] mean=total/count print("Mean : {}".format(mean))
17th Oct 2021, 10:07 AM
Jasy Fabiano
Jasy Fabiano - avatar
+ 1
Jasy Fabiano Great code buddy, but a learner will not learn anything from it without an explanation. Some people will just copy/paste and take credit from your efforts.
17th Oct 2021, 10:10 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Yes
17th Oct 2021, 10:44 AM
A.K.-GAMERZ __YT
A.K.-GAMERZ __YT - avatar