TORONTO KIDS COMPUTER CLUB | Aurora Saturday 13:00 Python Practice 11.28.
18790
post-template-default,single,single-post,postid-18790,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Saturday 13:00 Python Practice 11.28.

02 Dec Aurora Saturday 13:00 Python Practice 11.28.

Question:

Create a PWD(Password) class it will contain the following methods:

__init__

  • to create a password object by passing one argument into it

validate

  • to check the validity of password input by users. it need to use the following method:
    • checkLetter: At least 1 letter between [a-z] and 1 letter between[A-Z].
    • checkNumber: At least 1 number between [0-9].
    • checkSymbol: At least 1 character from [$#@].
    • checkLength: Minimum length 6 characters. Maximum length 16 characters.

Sample program:

class PWD:
    def __init__(self, password):
        ... ...

    def validate(self):
        ... ...

    def checkLetter(self): 
        ... ...
    def checkNumber(self): 
        ... ...
    def checkSymbol(self): 
        ... ...
    def checkLength(self): 
        ... ...
myPwd = PWD(input("Please enter your password:"))
if myPwd.validate() == True:
    print("password validated!")

Sample input 1:
Please enter your password: admin123

Sample output 1:
Missing at least 1 character from [$#@]


Sample input 2:
Please enter your password: admin123$

Sample output 2:
password validated!

No Comments

Sorry, the comment form is closed at this time.