Search Header Logo
Understanding Python If Statements

Understanding Python If Statements

Assessment

Flashcard

•

Computers

•

9th Grade

•

Practice Problem

•

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

5 questions

Show all answers

1.

FLASHCARD QUESTION

Front

Which of the following is a correct example of an if-else ladder in Python? Options: ```python
if x > 10:
print("Greater than 10")
elif x > 5:
print("Greater than 5")
else:
print("5 or less")
```

Back

```python
if x > 10:
print("Greater than 10")
elif x > 5:
print("Greater than 5")
else:
print("5 or less")
```

Answer explanation

If statement ladders are used to evaluate non-binary choices, and follow the form:

if (condition is true):

do:

elif (condition is true):

do:

else:

do default action when neither

condition is met.

2.

FLASHCARD QUESTION

Front

Which of the following Boolean expressions will evaluate to True if x=7x = 7 and y=5y = 5 ? x<yx < y , x==yx == y , x>yx > y , x≤yx \leq y

Back

x>yx > y

3.

FLASHCARD QUESTION

Front

What will be the output of the following code snippet?
```python
x = 10
y = 20
if x < y:
print("x is less than y")
else:
print("x is not less than y")
```
Options:
- x is less than y
- x is not less than y
- Error
- No output

Back

x is less than y

4.

FLASHCARD QUESTION

Front

Which of the following is a valid comparison operator in Python? Options: <> , == , != , =

Back

==

Answer explanation

In programming languages, the comparison operator is double equal ==== .

The single equal, == , is the assignment operator and is used to set the value of a variable.

Not equal (!=) is used in boolean logic, but is not the comparison operator as the result is true only if the two values under comparison are not equal.

5.

FLASHCARD QUESTION

Front

What will be the result of the following Boolean expression: (5>3)∧(2<4) (5 > 3) \land (2 < 4) ?

Back

True

Answer explanation

When we encounter a compound boolean expression that includes ∧\wedge both sides of the expression need to be true. If either side of the expression is false, the entire expression is false.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?