In: Computer Science
URGENT PLZ - BASIC PYTHON
Use the following format for each of your files in the header.
# Name:
# Date:
# Description:
You programs should be FULLY COMMENTED.
Mr. Zapanta has locked himself out of his laptop and completely forgotten his password (the password is “cardinalcarter123” or “CardinalCarter123”). Write a program that generates a password entry. The program will display an appropriate message if Mr. Zapanta enters the wrong password. The program will allow a maximum of 5 tries to enter. If he exceeds 5 tries, the program will stop and display “Your laptop has been locked”. (5 marks Thinking) (Use a while loop)
Sample Output 1:
Enter the password: mr. zapanta
That is not the correct password! Try again.
Enter the password: cardinal carter
That is not the correct password! Try again.
Enter the password: ilovecompsci
That is not the correct password! Try again.
Enter the password: carter123
That is not the correct password! Try again.
Enter the password: chicken321!
That is not the correct password! You’ve reached the max number of tries.
Your laptop has been locked.
Sample Output 2:
Enter the password: mr. zapanta
That is not the correct password! Try again.
Enter the password: cardinalcarter123
Welcome, Mr. Zapanta.
Here is the code:
def password_check():
    n = 0
    while(n <= 5):
        password = input('Enter password: ')
        n += 1
        if(password == 'cardinalcarter123' or password == 'CardinalCarter123'):
            print('Welcome, Mr. Zapanta.')
            break
        elif(n == 5):
            print('That is not the correct password! You’ve reached the max number of tries. Your laptop has been locked.')
            break
        else:
            print('That is not the correct password! Try again.')
            
# calling the function
password_check()
Here is the output:

For any doubts, please comments below.