Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure

Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user.

The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer than 15 characters), the program must print out all of the things that are wrong, and how to fix them.

The program follows these rules for passwords:

  1. The password must contain at least one lowercase letter.

  2. The password must contain at least one uppercase letter.

  3. The password must be between 6 and 20 characters, inclusive.

    a. If the password is between 6 and 13 characters, inclusive, it must contain a 7 somewhere in the password.

    b. If the password is between 14 and 20 characters, inclusive, itmust contain a 2 somewhere in the password.

  4. The password cannot contain the characters 0 and O (zero anduppercase o) at the same time. (It can contain a 0 or an O, just notboth at the same time. It may also contain neither.)

For this part of the homework, you must have an in-line comment at the top of each of your programs individual if, elif, and else statements, explaining what is being checked by that conditional.

(HINT: Think carefully about what your conditionals should look like. If necessary, draw a truth table to help figure out what different inputs will do. Using a Boolean flag will also likely make this easier.)

(See the next page for sample output.)

Here is some sample output for hw4_part3.py, with the user input in blue. (Yours does not have to match this word for word, but it should be similar.)

linux1[8]% python hw4_part3.py Please enter a password: dogs Password must have an uppercase character Password must be at least 6 characters Please enter a password: DOGS Password must have a lowercase character Password must be at least 6 characters Please enter a password: Dogs Password must be at least 6 characters Please enter a password: Doggos Shorter passwords must contain a 7 Please enter a password: 7Doggos Thank you for picking the secure password 7Doggos 

linux1[9]% python hw4_part3.py Please enter a password: thisMustBeSecureItsLongAlso27Password must be no longer than 20 characters Please enter a password: abcdefghijklmnopqrst Password must have an uppercase character Longer passwords must contain a 2 Please enter a password: 2and7EQUALSnine Thank you for picking the secure password 2and7EQUALSnine

linux1[10]% python hw4_part3.py Please enter a password: O_and_0 Shorter passwords must contain a 7 Password cannot contain a O and a 0 at the same time Please enter a password: O_and_7 
Thank you for picking the secure password O_and_7 

linux1[11]% python hw4_part3.py Please enter a password: greatPassword7! Longer passwords must contain a 2 Please enter a password: greatPassword2! Thank you for picking the secure password greatPassword2!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions