Python题解 | #密码强度等级#

密码强度等级

https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361

import sys


while True:
    try:
        s = input()
        l, w, d, c = 0, 0, 0, 0
        if len(s) <= 4:
            l = 5
        elif 5 <= len(s) <= 7:
            l = 10
        elif len(s) >= 8:
            l = 25
        
        a = [0] * 2
        num = 0
        ch = 0
        for i in s:
            if i.isupper():
                a[0] += 1
            elif i.islower():
                a[1] += 1
            elif i.isdigit():
                num += 1
            else:
                ch += 1
        
        if (num + ch) == len(s):
            w = 0
        elif a[0] + (num + ch) == len(s) or a[1] + (num + ch) == len(s):
            w = 10
        elif a[0] != 0 and a[1] != 0:
            w = 20
        

        if num == 0:
            d = 0
        elif num == 1:
            d = 10
        elif num > 1:
            d = 20

        if ch == 0:
            c = 0
        elif ch == 1:
            c = 10
        elif ch > 1:
            c = 25
        
        j = 0
        if (a[0] != 0 and num != 0) or (a[1] != 0 and num != 0):
            j = 2
        if (a[0] != 0 and num != 0 and ch != 0) or (a[1] != 0 and num != 0 and ch != 0):
            j = 3
        if a[0] != 0 and a[1] != 0 and num != 0 and ch != 0:
            j = 5
        
        sum_score = l + w + d + c + j
        if sum_score >= 90:
            print('VERY_SECURE')
        elif 90 > sum_score >= 80:
            print('SECURE')
        elif 80 > sum_score >= 70:
            print('VERY_STRONG')
        elif 70 > sum_score >= 60:
            print('STRONG')
        elif 60 > sum_score >= 50:
            print('AVERAGE')
        elif 50 > sum_score >= 25:
            print('WEAK')
        else:
            print('VERY_WEAK')


        
        

    except:
        break

全部评论
不必理会
点赞 回复 分享
发布于 2024-05-17 23:24 上海

相关推荐

牛客ID:561366855:期望薪资多少?难以相信这简历找不到工作。说明二本电子信息专业想对口就业非常难。
点赞 评论 收藏
分享
有没有友友知道hr面会问什么我应该反问什么?还有如何防止hr套话啊?还有应该如果催hr推进快一点#字节#OPPO#hr面
牛客989988346号:职业规划,优缺点,为什么选择这个岗,对应聘公司产品的了解和满意度,如果让你改进公司产品你会怎么做,对ai(新技术)的了解,有无其他offer,什么时候能到岗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务