难不难,就是要求比较多,用函数分开来写就行了
``` python []
#密码长度得分计算
def lenscore(x):
if 0<len(x)<=4:
return 5
elif 5<=len(x)<=7:
return 10
elif len(x)>=8:
return 25
else:
return 0
#字母大小写得分计算
def zimuscore(x):
x=str(x)
a=0#计算小写个数
b=0#计算大写个数
for i in x:
if i.islower():#计算小写
a+=1
if i.isupper():#计算大写
b+=1
if (a!=0 and b==0) or (b!=0 and a==0):#全是小写或者全是大写
return 10
if a!=0 and b!=0:#大小写混合
return 20
else:
return 0
#数字得分计算:
def digtscore(x):
x=str(x)
a=0#计算数字个数
for i in x:
if i.isdigit():
a+=1
if a==1:
return 10
if a>1:
return 20
else:
return 0
#符号得分计算
def fhscore(x):
x=str(x)
a=0#计算符号个数
fsm="!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"
for i in x:
if i in fsm:
a+=1
if a==1:
return 10
if a>1:
return 25
else:
return 0
#奖励得分计算
def jlscore(x):
x=str(x)
a=0#计算小写个数
b=0#计算大写个数
for i in x:
if i.islower():#计算小写
a+=1
if i.isupper():#计算大写
b+=1
if ((a!=0 and b==0) or (b!=0 and a==0)) and digtscore(x)!=0:#字母加数字
return 2
if ((a!=0 and b==0) or (b!=0 and a==0)) and digtscore(x)!=0 and fhscore(x):#字母加数字加符号
return 3
if (a!=0 and b!=0) and digtscore(x)!=0 and fhscore(x):#大小写字母加数字加符号
return 5
else:
return 0
while True:
try:
a=str(input())
countscore=lenscore(a)+zimuscore(a)+digtscore(a)+fhscore(a)+jlscore(a)
#print(countscore)
if countscore>=90:
print("VERY_SECURE")
if 80<=countscore<90:
print("SECURE")
if 70<=countscore<80:
print("VERY_STRONG")
if 60<=countscore<70:
print("STRONG")
if 50<=countscore<60:
print("AVERAGE")
if 25<=countscore<50:
print("WEAK")
if 0<=countscore<25:
print("VERY_WEAK")
except:
break