Question: Declare and set values for variables needed throughout the code[MB1] A string containing the target password: wahtZ9t[MB2] % A limit for attempts at entering the

Declare and set values for variables needed throughout the code[MB1]

  • A string containing the target password: wahtZ9t[MB2] %
  • A limit for attempts at entering the password: 3[MB3]
  • A Boolean value to show if the user succeeded in entering the password (or not)

Create an iterative structure/ OR A LOOP to execute up to 3 times: (USE A RANGE FUNCTION)

  • Prompt the user for a password[MB4]
  • If the entered password matches the target:
    • Output a success message that includes the number of tries needed to get the password right
    • Exit the loop (EXIT LOOP AFTER FIRST AND SECOND ATTEMPT ARE MADE IF CORRECT-DONT ASK AGAIN FOR PASSWORD)
  • Otherwise:

Output a failure message, including the number of attempts left[MB5]

Return to the top of the loop[MB6]

(AFTER YOU EXIT THE LOOP) If the user failed in three attempts to get the password:

  • Output a message that the users password has been revoked

HARD Requirements:

1. Name your code passwordCheck.py.

2. Use the range function to control the iterative structure.

3. Exit the loop when the user enter a correct password. That is, if the user enters the correct password on the first attempt, do not prompt them for the password again.

4. Use a mathematical expression to determine remaining attempts.

5. Use a Boolean variable to track overall success or failure.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!