嗨,我需要以两种方式完成这项任务:一种方式使用 for 循环,另一种方式使用 while 循环,但我没有 secceed....我写的代码是:
A = [5,8,9,1,2,4]
AV = sum(A) / float(len(A))
count = 0
for i in A :
if i > AV :
count = count + 1
print ("The number of elements bigger than the average is: " + str(count))
count = 0
while float in A > AV:
count += 1
print ("The number of elements bigger than the average is: " + str(count))