Fill This Form To Receive Instant Help
Homework answers / question archive / CS119 Python Programming PJ 5 – Password Game Please write a Python program to check a password and print all the violations of this password if any
CS119 Python Programming
PJ 5 – Password Game
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:
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 name
1 ============================================================.
Please enter a password (Enter q to quit): a b
The 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): 2020
The 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$2015ok
The password you just entered is "PW$2015ok"
Congratulations! Your password is very secure!
4 ============================================================.
Please enter a password (Enter q to quit): DrLin2014
The 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 here
The 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): OKpassword
The 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): q
9 ============================================================.
Thank you for playing this PASSWORD game of "Dr. Simon Lin"! ? You must use your name
10 ============================================================.
You may use the following framework to finish your program.
--------------------------------------------------------------------------------------------------------------------------.
# Author: Dr. Simon Lin # must use your name
# Date: 9/01/2021
# Purpose: CS119-PJ5: Password Game – to check whether a password is very secure.
n = 1 # line number for each separator line
print ("Welcome to the PASSWORD game of \"Dr. Simon Lin\"!") # must use your name
print (n,"============================================================"); n+=1;
pw = input( "Please enter a password (Enter q to quit): ") # pw is a string
while (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 26 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 26 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 10 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 4 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 ============================================.
=========================================================================.
How to submit your Project Assignment (PJ)?
(1) Each program must be well documented with block comments and proper line comments.
The beginning of each program must have a block comment to show its author, date, and purpose.
The following is an example of block comments:
# Author: _______________ ? must use your full name here!
# Date: _______________ ? must show today’s date here!
# Purpose: _______________ ? must show the purpose of this program here!
(2) You must submit to Canvas the following two items as attachments:
(a) Your source program (for example, CS119-PJ5.py ), and
(b) Your WORD document (for example, CS119-PJ5-report .docx ) containing the listing of
your Python program, and the complete output of your 3 test runs as specified.
You must not submit a zip file to Canvas.
=========================================================================.
//You must delete everything above & including this line to make this your Word document to be submitted.
PJ 5 Report My Name: ________________
A. The following is my Python source program:
// Please copy your source program into here from your Visual Studio IDE.
// Your code here must be in color. You must not show screen prints here.
B. The following is the console output of my 3 test runs:
// One way to copy the console output is to press Ctrl+Alt+PrtScn, which is a screen print.
// Another way to copy is to use the snipping tool. To paste the image is to press Ctrl+v.
// The console display must not be too wide, otherwise it will be too hard to read once pasted.
// Please make sure your console is long enough to show all your output lines, and is readable.
// Please copy your console output and paste into here:
Test Run #1:
Test Run #2:
Test Run #3:
Please download the answer file using this link
https://drive.google.com/file/d/1y3YTFSoGsRfyN6-jltCACY1TrKqy6hgE/view?usp=sharing