Using IF statements Flashcards
What will the condition always have?
A logical operator
What will happen if the condition is False?
The code block indented under the ELSE will run.
In this code:
password = open123
guess = input(“Enter Password: “)
if guess == password:
print(“access granted”)
else:
print (“password incorrect”)
What happens in line two?
The program stores a user input before using the variable in the IF statements.
In this code:
password = open123
guess = input(“Enter Password: “)
if guess == password:
print(“access granted”)
else:
print (“password incorrect”)
What is happening in line three?
The condition is comparing both variables.
What are ELSEs useful for?
To show errors as it’s the last chance to communicate to the user.