본문 바로가기

Python_Matter/[Check_IO]Elementary

Acceptable Password I

반응형

Quiz>

You are the beginning of a password series.

Every mission will be based on the previous one.

Going forward the missions will become slightly more complex.

 

In this mission you need to create a password verification function.

 

Those are the verification conditions:

 

the length should be bigger than 6.

Input:

A string.

 

Output:

A bool.

 

Example:

is_acceptable_password('short') == False
is_acceptable_password('muchlonger') == True

 

How it’s used:

For password verification form. Also it’s good to learn how the task can be evaluated.

 

def is_acceptable_password(password: str) -> bool:
    # your code here
    return True


if __name__ == '__main__':
    print("Example:")
    print(is_acceptable_password('short'))

    # These "asserts" are used for self-checking and not for an auto-testing
    assert is_acceptable_password('short') == False
    assert is_acceptable_password('muchlonger') == True
    assert is_acceptable_password('ashort') == False
    print("Coding complete? Click 'Check' to earn cool rewards!")

 

Solve>

1. 패스워드 길이가 6글자 이상 되어야지만 True를 반환한다.

def is_acceptable_password(password: str):
    if len(password) > 6:
        return True
    else:
        return False

 

Code>

def is_acceptable_password(password: str):
    if len(password) > 6:
        return True
    else:
        return False

 

Example>

if __name__ == '__main__':
    print("Example:")
    print(is_acceptable_password('short'))

    # These "asserts" are used for self-checking and not for an auto-testing
    assert is_acceptable_password('short') == False
    assert is_acceptable_password('muchlonger') == True
    assert is_acceptable_password('ashort') == False
    print("Coding complete? Click 'Check' to earn cool rewards!")

 

Result>

Example:

False

Coding complete? Click 'Check' to earn cool rewards!

반응형

'Python_Matter > [Check_IO]Elementary' 카테고리의 다른 글

End Zeros  (0) 2020.04.11
Number Length  (0) 2020.04.11
All Upper I  (1) 2020.04.11
Correct Sentence  (0) 2020.04.11
Fizz Buzz  (0) 2020.04.11