3.2 Code Practice: Question 3
Test if a password entered is correct. The secret phrase is Ada Lovelace.
Answers
Answer:
x = str(input("Enter the Password:"))
if (x == "Ada Lovelace"):
print ("Correct!")
if (x != "Ada Lovelace"):
print ("Not Correct")
Explanation:
Answer:
A simple program in Python that tests if a password entered is correct.
Explanation:
From the above question,
They have given :
Here is a simple program in Python that tests if a password entered is correct:
secret_phrase = "Ada Lovelace"
input_phrase = input("Enter the password: ")
if input_phrase == secret_phrase:
print("Access granted.")
else:
print("Access denied.")
The program defines a secret_phrase string variable that holds the correct password, "Ada Lovelace".
The program then prompts the user to enter a password using the input() function, which returns the entered text as a string and stores it in the input_phrase variable.
Next, the program uses an if statement to compare the value of input_phrase to the secret_phrase. If the two values are equal, the program outputs "Access granted.". If the values are not equal, the program outputs "Access denied.".
This program provides a basic implementation of password validation, where the user must enter the exact same text as the secret_phrase for the program to grant access. In a real-world scenario, you would want to secure the password and implement stronger validation methods such as hashed passwords and salted hashes.
For more such related questions : https://brainly.in/question/32667309
#SPJ3