If statements Flashcards

1
Q

What is the correct syntax for creating a basic if statement in Python?

A

Indentation

if num in nums:
return True

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

What is the correct syntax for if, else if, and else in Python?

A

if, elif, else

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

How do you do “logical and” and “logical or” in Python?

A

and, or (other languages are &&, ||)

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

What is the correct syntax when doing multiline conditionals?

A

if ((n > 2 and
n != m) or n == m):
n += 1

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