Using IF statements Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What will the condition always have?

A

A logical operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What will happen if the condition is False?

A

The code block indented under the ELSE will run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In this code:
password = open123
guess = input(“Enter Password: “)
if guess == password:
print(“access granted”)
else:
print (“password incorrect”)

What happens in line two?

A

The program stores a user input before using the variable in the IF statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

The condition is comparing both variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are ELSEs useful for?

A

To show errors as it’s the last chance to communicate to the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly