题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
# 2024年10月14日 上午10:44
s = input()
sc = 0
# 1 密码长度
if 0 <= len(s) <= 4:
sc += 5
elif 5 <= len(s) <= 7:
sc += 10
elif len(s) >= 8:
sc += 25
up = 0
lw = 0
num = 0
ot = 0
for i in s:
if i.islower():
lw += 1
elif i.isupper():
up += 1
elif i.isdigit():
num += 1
else:
ot += 1
# 2 字母
if (lw + up) == 0:
sc += 0
elif (lw != 0 and up == 0) or (lw == 0 and up != 0):
sc += 10
elif lw != 0 and up != 0:
sc += 20
# 数字
if num == 0:
sc += 0
elif num == 1:
sc += 10
elif num > 1:
sc += 20
# 符号
if ot == 0:
sc += 0
elif ot == 1:
sc += 10
elif ot > 1:
sc += 25
# 奖励
if (lw != 0 and up == 0) or (up != 0 and lw == 0) and (num != 0) and (ot == 0):
sc += 2
elif (lw != 0 and up == 0) or (lw == 0 and up != 0) and (num != 0) and (ot != 0):
sc += 3
elif (lw != 0 and up != 0) and (num != 0) and (ot != 0):
sc += 5
#print(sc)
if sc >= 90:
print("VERY_SECURE")
elif sc >= 80:
print("SECURE")
elif sc >= 70:
print("VERY_STRONG")
elif sc >= 60:
print("STRONG")
elif sc >= 50:
print("AVERAGE")
elif sc >= 25:
print("WEAK")
elif sc >= 0:
print("VERY_WEAK")


