+ 1

# Help me wiht python

An integer array of 30 elements is given. Array elements can take values from 1 to 5 – annual computer science assessments of graduating students. Describe the algorithm that calculates and outputs the average score among good performers (those who received a final grade of 4 or 5). It is guaranteed that there is at least one good teacher in the class.

2nd Feb 2023, 4:31 PM
Dmitry
+ 7
Dmitry , > what kind of issue do you have? > please also save your code attempt in playground and link it here. without having seen your code if is difficulg to help.
2nd Feb 2023, 4:35 PM
Lothar + 7
Dmitry , i have taken your code and have tried some improvements, also some comments. 1) generating the array can be simplified (see the code sample) 2) see how the code could be working (see the code sample) https://code.sololearn.com/clafXZNMjYUT/?ref=app
2nd Feb 2023, 8:06 PM
Lothar + 2
Lothar, thank you very much✌️
2nd Feb 2023, 8:09 PM
Dmitry
+ 1
from random import randint a=[] n=30 count=0 s=0 ball=0 for i in range(n): a.append(randint(1,5)) print(a) for j in range(n): if a[j] >=4: count+=1 print(count) I find it difficult that I don’t know how to declare the sum of the array elements (that is, the sum of all 4 and 5)
2nd Feb 2023, 4:47 PM
Dmitry
+ 1
Simply add the elements that fit the condition to the variable s you declared and then divide it with count to get the average?
2nd Feb 2023, 5:00 PM
Lochard 