Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python: write a function that checks whether a string is a valid password, suppose the password rules are as follows: -A password must have

In python: write a function that checks whether a string is a valid password, suppose the password rules are as follows:

-A password must have at least eight characters.

-A password must consist of only letters and digits.

A password must contain at least two digits

Have the program:

Begin the program and each function with a comment.

Define a function to prompt the user for a password and return it to main( ).

Define a second function to check the password and return True if it is valid, else False. Call this from main( ), also.

Run your program with test cases demonstrating valid passwords and each of the following error cases, with appropriate error messages.

Show multiple error messages for multiple infractions. See 5th test case below.

Use local variables, rather than global.

Use structured code (e.g., no unstructured exits from loops).

Test Cases:

1) abcd1234 is valid.

2) Password must be at least 8 characters long.

abcd123 is invalid.

3) Password must have at least 2 digits.

abcdefg8 is invalid.

4) Password must be alphanumeric.

abcd123* is invalid.

5) Password must be at least 8 characters long.

Password must have at least 2 digits.

Password must be alphanumeric.

abc3* is invalid.

Hints: use the following to help write the program

-len( )

- isalnum( )

- isdigit( ) can also be used for characters

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago