Question

In: Computer Science

URGENT PLZ - BASIC PYTHON Use the following format for each of your files in the...

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.

  1. 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.


Solutions

Expert Solution

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.


Related Solutions

This is a machine learning question. Please use python and google colab format. PLEASE USE BASIC...
This is a machine learning question. Please use python and google colab format. PLEASE USE BASIC MACHINE LEARNING CODES. Using the Kaggle diamonds dataset, construct a KNN estimator to predict diamond prices. Choose an appropriate K value and predict the price of a diamond with the following parameters: "carat' : 0.32, 'cut' : Ideal, 'color' : E, 'clarity' : IF, 'depth' : 60.7, 'table' : 58.0, 'x' : 4.46, 'y' : 4.48,  'z': 2.71". Please change the cut, color and clarity...
python . The two csv files will contain lines in the following format: Angle, time, speed...
python . The two csv files will contain lines in the following format: Angle, time, speed - where each action will be specified as: • A, t, s = Move at an angle of A degrees with respect to East direction (positive horizontal axis) for t seconds with speed s meters per second.    The function should return 3 numpy arrays: • The expected horizontal displacements for each microcar • The expected vertical displacements for each microcar • The expected...
Python - files: find a solution for each following: -Open the file hostdata.txt for reading. -Store...
Python - files: find a solution for each following: -Open the file hostdata.txt for reading. -Store four file objects corresponding to the files winter2003.txt , spring2003.txt, summer2003.txt, and fall2003.txt in the variables winter, spring, summer, and fall (respectively), and open them all for reading. -Write a statement to open the file yearsummary.txt in a way that erases any existing data in the file. -Use the file object output to write the string "3.14159" to a file called pi. -A file...
In Python This assignment involves the use of text files, lists, and exception handling and is...
In Python This assignment involves the use of text files, lists, and exception handling and is a continuation of the baby file assignment. You should now have two files … one called boynames2014.txt and one called girlnames2014.txt - each containing the top 100 names for each gender from 2014. Write a program which allows the user to search your files for a boy or girl name and display where that name ranked in 2014. For example … >>>   Enter gender...
Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors.
Each of the following files in the Chapter15 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fix. For example, DebugFifteen1.java will become FixDebugFifteen1.java. a. DebugFifteen1.java b. DebugFifteen2.java c. DebugFifteen3.java d. DebugFifteen4.java    
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data...
2. Combine multiple files Use Python programming to combine two text files: customer-status.txt and sales.txt Data columns in customer-status.txt (separated by comma): Account Number, Name, Status 527099,Sanford and Sons,bronze Data columns in sales.txt (separated by comma): Account Number, Name, SKU, Quantity, Unit Price, Ext Price, Date 163416,Purdy-Kunde,S1-30248,19,65.03,1235.57,2014-03-01 16:07:40 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01 After you combine, you will see the following: 527099,Sanford and Sons,S2-82423,3,76.21,228.63,2014-03-01 17:18:01,bronze
Python Write a for loop with a range function and format output as currency Use an...
Python Write a for loop with a range function and format output as currency Use an input statement to ask the user for # of iterations using the prompt: #? [space after the ?] & assign to a variable Convert the variable to an integer Use a for loop and a range function to display all whole numbers from 1 to the user entered number Display the value of the item variable on screen in each iteration in the following...
On Python a) Use format() method to print an integer value entered by the user and...
On Python a) Use format() method to print an integer value entered by the user and its cube root with two decimal places. b) Print the same values as part (a) using format() function with keyword arguments and labels number and cubeRoot as in: format(number=n,cubeRoot=cr) c) Switch the order of keyword arguments and show that this has no effect on the output.
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file...
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file module6data.txt (Below) Write a program that will a. Open the file module6data.txt b. Create a second file named processed. txt c. Read the numbers from the first file one at a time. For each number write into second file, if possible, its I. Square ii. Square root iii. Reciprocal (1/number)use a math module function for the square root. use exception handling to trap possible...
Python programming ***************************************************************************************************** If we load the json files then how could we use the objects...
Python programming ***************************************************************************************************** If we load the json files then how could we use the objects to extract particular values from those files. eg: fi1 = open("king.json", "rb") obj1 = yaml.safe_load(fi1.read()) fi1.close() fi2 = open("queen.json", "rb") obj2 = yaml.safe_load(fi2.read()) fi2.close() Now if the JSON file queen.json had elements like name, rule year, children, etc. and we wanted the name of the queen who ruled between particular years, how would we do it? second would be getting a value common for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT