Python Booleans & Truth Values Quiz

Python
0 Passed
0% acceptance

A 35-question quiz covering boolean logic, truthy/falsy values, operators, and conditional expressions.

35 Questions
~70 minutes
1

Question 1

What is the data type of the value `True` in Python?

A
bool
B
int
C
str
D
boolean
2

Question 2

Analyze the code below. What will be the output?

python
print(True + True)
A
2
B
TrueTrue
C
True
D
Error
3

Question 3

Which of the following values is considered 'falsy' in Python?

A
0
B
-1
C
"False"
D
[0]
4

Question 4

What is the result of the expression `True and False`?

A
False
B
True
C
None
D
Error
5

Question 5

Analyze the code below. What is the value of `result`?

python
x = 10
y = 20
result = x > 5 and y < 30
A
True
B
False
C
10
D
20
6

Question 6

What does the `not` operator do?

A
It inverts the boolean value of its operand.
B
It makes a value negative.
C
It checks if a value is None.
D
It converts a value to False.
7

Question 7

Consider the following expression using short-circuit evaluation. What is the final result?

python
result = True or (5 / 0)
A
True
B
ZeroDivisionError
C
False
D
None
8

Question 8

What is the output of `bool([])`?

A
False
B
True
C
None
D
Error
9

Question 9

Which comparison operator checks if two variables point to the exact same object in memory?

A
is
B
==
C
=
D
in
10

Question 10

Analyze the code below. What will be printed?

python
if "Hello":
    print("Yes")
else:
    print("No")
A
Yes
B
No
C
Error
D
Nothing
11

Question 11

What is the result of `not 0`?

A
True
B
False
C
1
D
-1
12

Question 12

Which of the following expressions evaluates to `True`?

A
5 != 5
B
5 == 5.0
C
5 is 5.0
D
5 > 10
13

Question 13

What is the precedence of boolean operators in Python (from highest to lowest)?

A
not, and, or
B
and, or, not
C
or, and, not
D
not, or, and
14

Question 14

Analyze the code below. What is the value of `x`?

python
x = 10 or 20
A
10
B
20
C
True
D
False
15

Question 15

What is the result of `bool(None)`?

A
False
B
True
C
None
D
Error
16

Question 16

Which statement correctly checks if a variable `is_valid` is False?

A
if not is_valid:
B
if is_valid == Nothing:
C
if is_valid is 0:
D
if !is_valid:
17

Question 17

What is the output of the following chained comparison?

python
x = 5
print(1 < x < 10)
A
True
B
False
C
Error
D
1
18

Question 18

What is the result of `True and 0`?

A
0
B
True
C
False
D
None
19

Question 19

Which of the following is equivalent to `bool(1)`?

A
True
B
False
C
1
D
None
20

Question 20

Analyze the code below. What is the output?

python
a = True
b = False
print(a or b and a)
A
True
B
False
C
Error
D
None
21

Question 21

What is the result of `False == 0`?

A
True
B
False
C
Error
D
None
22

Question 22

Which logical operator requires both operands to be false to return False?

A
or
B
and
C
not
D
xor
23

Question 23

What is the output of `bool(' ')` (a string with a single space)?

A
True
B
False
C
None
D
Error
24

Question 24

Analyze the code below. What is the value of `check`?

python
check = (1, 2) == [1, 2]
A
False
B
True
C
Error
D
None
25

Question 25

What is the result of `any([False, False, True])`?

A
True
B
False
C
None
D
Error
26

Question 26

What is the result of `all([True, True, 1])`?

A
True
B
False
C
1
D
Error
27

Question 27

Which expression correctly checks if `x` is strictly between 10 and 20?

A
10 < x < 20
B
x > 10 and < 20
C
10 < x and 20
D
between(x, 10, 20)
28

Question 28

What is the result of `not not 5`?

A
True
B
False
C
5
D
None
29

Question 29

Analyze the code below. What is printed?

python
if 0:
    print("A")
elif []:
    print("B")
else:
    print("C")
A
C
B
A
C
B
D
Nothing
30

Question 30

What is the result of `True is not False`?

A
True
B
False
C
Error
D
None
31

Question 31

Which value is returned by `1 and 2 and 3`?

A
3
B
1
C
True
D
False
32

Question 32

What is the result of `bool(range(0))`?

A
False
B
True
C
None
D
Error
33

Question 33

Analyze the code below. What is the value of `flag`?

python
flag = "False" == False
A
False
B
True
C
Error
D
None
34

Question 34

Which of the following is the correct way to assign a boolean value to a variable?

A
is_active = True
B
is_active = true
C
is_active = 'True'
D
is_active = 1
35

Question 35

What is the result of `not (True or False)`?

A
False
B
True
C
None
D
Error

QUIZZES IN Python