python: collections counter
entrance_fee = [70, 80, 105, 110, 120, 125]
entrance_fee = entrance_fee + [0]
index =6
k = 0
while k<6 and index==6: # 因为这里index 是6 ,初始值必须是6
if 115<entrance_fee[k]:
index=k
k=k+1
print("index",index)
for k in range(6,index,-1):
entrance_fee[k]=entrance_fee[k-1]
entrance_fee[index]=115
print(entrance_fee)
result = ['Pass', 'Fail', 'Pass', 'Pass', 'Pass', 'Pass', 'Pass', 'Pass', 'Pass', 'Pass']
p=Counter(result) # 引用库 from collections import Counter
#print(dict(p)) #分类计数的结果
#print(p['Pass'])
if(p["Pass"]>=5):
print("S/he gets the certificate of completion.")
else:
print("S/he needs to pass more tests.")
while True:
num=0
P=0
result = []
#也可以用while 或for
s=0
while num<10 and P<=5: #当达到5时,就可以确定极格,不用再计数了
s=num+1
test=input(str(s)+":input Pass/Fail")
result.append(test.strip()) #去除两头空格
num+=1
'''
for k in range(0,10):
num=k+1
test = input(str(num)+":input Pass/Fail")
result.append(test.strip()) # 去除两头空格
'''
print("score",result)
for k in range(0, 10):
if result[k] == "Pass":
P = P + 1
if P == 5: #5极格了,就结束
break
if P >= 5:
print("S/he gets the certificate of completion.")
else:
print("S/he needs to pass more tests.")
yn=input("Whether to continue testing(Y/N)?")
if(yn=='Y' or yn=='y'):
continue
else:
break
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)