Question: Please write a Python program to check a password and print all the violations of this password if any. You must print Congratulations! Your password
Please write a Python program to check a password and print all the violations of this password if any. You must print "Congratulations! Your password is very secure!" if there is no violations at all for this password. The password q is the only way to quit this password checking game. All the possible 10 violations to be detected by your program are as follows:1. R1: Your password is not secure since it has less than 2 upper-case letters.2. R2: Your password is not secure since it has less than 2 lower-case letters.3. R3: Your password is not secure since it has less than 7 characters.4. R4: Your password is not secure since it has less than 2 digits.5. R5: Your password is not secure since it has more than 12 characters.6. R6: Your password is not secure since it contains space.7. R7: Your password is not secure since it contains only digits.8. R8: Your password is not secure since it contains only alphabets. 9. R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *10. R10: Your password is not secure since it contains 2020, 2019, 2018, or 2017.You must test your game program 3 times. Your test case #1 must look exactly as follows including the data. You must also do test case #2 and test case #3 with different data of at least 7 passwords. Each test case or test run must begin with a welcome message, and must end with a thank-you message. Welcome to the PASSWORD game of "Dr. Simon Lin"! You must use your name1 ============================================================.Please enter a password (Enter q to quit): a bThe password you just entered is "a b"R1: Your password is not secure since it has less than 2 upper-case letters.R3: Your password is not secure since it has less than 7 characters.R4: Your password is not secure since it has less than 2 digits.R6: Your password is not secure since it contains space.R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *Your password has the above 5 problems to be fixed.2 ============================================================.Please enter a password (Enter q to quit): 2020The password you just entered is "2020"R1: Your password is not secure since it has less than 2 upper-case letters.R2: Your password is not secure since it has less than 2 lower-case letters.R3: Your password is not secure since it has less than 7 characters.R7: Your password is not secure since it contains only digits. R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *R10: Your password is not secure since it contains 2020, 2019, 2018, or 2017.Your password has the above 6 problems to be fixed.3 ============================================================.Please enter a password (Enter q to quit): PW$2015okThe password you just entered is "PW$2015ok"Congratulations! Your password is very secure!
4 ============================================================.Please enter a password (Enter q to quit): DrLin2014The password you just entered is "DrLin2014"R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *Your password has the above 1 problems to be fixed.5 ============================================================.Please enter a password (Enter q to quit): just one space hereThe password you just entered is " "R1: Your password is not secure since it has less than 2 upper-case letters.R2: Your password is not secure since it has less than 2 lower-case letters.R3: Your password is not secure since it has less than 7 characters.R4: Your password is not secure since it has less than 2 digits.R6: Your password is not secure since it contains space.R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *Your password has the above 6 problems to be fixed.6 ============================================================.Please enter a password (Enter q to quit): Password123OK$The password you just entered is "Password123OK$"R5: Your password is not secure since it has more than 12 characters.Your password has the above 1 problems to be fixed.7 ============================================================.Please enter a password (Enter q to quit): OKpasswordThe password you just entered is "OKpassword"R4: Your password is not secure since it has less than 2 digits.R8: Your password is not secure since it contains only alphabets. R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *Your password has the above 3 problems to be fixed.8 ============================================================.Please enter a password (Enter q to quit): q9 ============================================================.Thank you for playing this PASSWORD game of "Dr. Simon Lin"! You must use your name10 ============================================================.You may use the following framework to finish your program.--------------------------------------------------------------------------------------------------------------------------.# Author: Dr. Simon Lin # must use your name# Date: 9/18/2020# Purpose: CS119-PJ5: Password Game to check whether a password is very secure.n = 1 # line number for each separator lineprint ("Welcome to the PASSWORD game of \"Dr. Simon Lin\"!") # must use your nameprint (n,"============================================================"); n+=1;pw = input( "Please enter a password (Enter q to quit): ") # pw is a stringwhile (pw != "q") : # q is to quit the game and exit this loop print("The password you just entered is \"" + pw + "\"") # password is quoted for clarity badcount = 0 # count # of problems countdigits = 0 # count # of digits countsymbols = 0 # count # of 6 special symbols $ % @ ! ? *
countlower = 0 # count # of lower-case letters countupper = 0 # count # of upper-case letters countyears = 0 # count # of 4-digit years 2020 2019 2018 2017 # Counting lower case letters: countlower += pw.count('a')+pw.count('b')+pw.count('c')+ # more coding here countlower += pw.count('h')+pw.count('i')+pw.count('j')+ # more coding here # Counting upper case letters: countupper += pw.count('A')+pw.count('B')+pw.count('C')+ # more coding here countupper += pw.count('H')+pw.count('I')+pw.count('J')+ # more coding here if (countupper # more coding here print("R1: Your password is not secure since it has less than 2 upper-case letters.") badcount += 1 if (countlower # more coding here print("R2: Your password is not secure since it has less than 2 lower-case letters.") badcount += 1 if ( len(pw) # more coding here print ("R3: Your password is not secure since it has less than 7 characters.") badcount += 1 # Counting digits in password countdigits += pw.count('0')+pw.count('1')+pw.count('2')+ # more coding here countdigits += pw.count('5')+pw.count('6')+pw.count('7')+ # more coding here if countdigits # more coding here print( "R4: Your password is not secure since it has less than 2 digits.") badcount += 1 if ( len(pw) # more coding here print ("R5: Your password is not secure since it has more than 12 characters.") badcount += 1 if pw.count(' ') > 0 : # space character check print( "R6: Your password is not secure since it contains space.")# more coding here if pw.isdigit( ) : # isdigit( ) will check whether pw contains only digits. print( "R7: Your password is not secure since it contains only digits. ") badcount += 1 if pw.isalpha( ) : # isalpha( ) will check whether pw contains only alphabets. print( "R8: Your password is not secure since it contains only alphabets. ") badcount += 1 # Counting 6 special symbols: countsymbols += pw.count('$')+pw.count('%')+ # more coding here if countsymbols # more coding here print( "R9: Your password is not secure since it contains none of 6 special symbols: $ % @ ! ? *") badcount += 1 # Counting special years: countyears += pw.count('2020')+pw.count('2019')+ # more coding here if (countyears # more coding here print("R10: Your password is not secure since it contains 2020, 2019, 2018, or 2017
badcount += 1 # Final check of badcount to see whether password is very secure: if badcount # more coding here print( "Congratulations! Your password is very secure!") else : print( "Your password has the above ", badcount, " problems to be fixed." ) pw = input( "Please enter a password (Enter q to quit): ") print (n,"============================================================"); n+=1; # end of while loop print (n,"============================================================"); n+=1;print("Thank you for playing this PASSWORD game of Dr. Simon Lin! ") # must use your name!print (n,"============================================================"); n+=1;# End of MAIN PROGRAM ============================================.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
