114k views
3 votes
You are trying to log in to your old computer, and can't remember the password. You sit for hours making random guesses... I'm sure you thought it was funny back when you came up with that password (chEEzburg3rz). Write a program that tells you whether your guess is correct. If it is correct, it should grant access like this: Enter password: chEEzburg3rz Access granted....

If your guess is incorrect it should deny access like this:
Enter password: lolcatZ
Access denied

1 Answer

5 votes

Answer:

The program written in Python is as follows (See Explanation Section for detailed explanation)

password = "chEEzburg3rz"

userpassword = input("Enter Password: ")

if userpassword == password:

print("Access granted....")

else:

print("Access Denied")

Step-by-step explanation:

The programming language was not stated; However, I answered your question using Python

The line initializes the password to chEEzburg3rz"

password = "chEEzburg3rz"

This line prompts user for input

userpassword = input("Enter Password: ")

This if condition checks if user input corresponds with the initialized password

if userpassword == password:

print("Access granted....") If yes, this line is executed

else:

print("Access Denied") If otherwise, this line is executed

User Marinelle
by
6.7k points