题解 | #密码强度等级#


"""
思路:将五个得分版块成绩汇总即可
"""
s = input()
res = 0
# 1.长度
if len(s) >= 8:
    res += 25
elif len(s) >= 5:
    res += 10
else:
    res += 5
# 2.字母
la = []
lu = []
ll = []
ln = []
for i in s:
    if i.isalpha():
        la.append(1)
    if i.isupper():
        lu.append(1)
    elif i.islower():
        ll.append(1)
    else:
        ln.append(1)
if sum(ln) == len(s):
    res += 0
elif sum(lu) == sum(la) or sum(ll) == sum(la):
    res += 10
else:
    res += 20
# 3.数字
ld = []
for i in s:
    if i.isdigit():
        ld.append(int(i))
if sum(ld) == 1:
    res += 10
elif sum(ld) > 1:
    res += 20
else:
    res += 0
# 4.符号
if len(ln) - len(ld) == 1:
    res += 10
elif len(ln) - len(ld) > 1:
    res += 25
else:
    res += 0
# 5.奖励
if (len(lu) > 0) and (len(ll) > 0) and (len(ld) > 0) and (len(ln) - len(ld) > 0):
    res += 5
elif (len(lu) + len(ll) > 0) and (len(ld) > 0) and (len(ln) - len(ld) > 0):
    res += 3
elif (len(lu) + len(ll) > 0) and (len(ld) > 0):
    res += 2
else:
    res += 0
# 输出结果
if res >= 90:
    print("VERY_SECURE")
elif res >= 80:
    print("SECURE")
elif res >= 70:
    print("VERY_STRONG")
elif res >= 60:
    print("STRONG")
elif res >= 50:
    print("AVERAGE")
elif res >= 25:
    print("WEAK")
else:
    print("VERY_WEAK")


全部评论

相关推荐

身边有人上海、深圳 6、7k 都去了,真就带薪上班了。
程序员小白条:木的办法, 以后越来越差,还是家附近宅着吧,毕业的人越来越多,岗位都提供不出来,经济又过了人口红利期
点赞 评论 收藏
分享
05-26 09:07
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务