wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Boolean and If

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.
A variable that can only have two values, True or False.
a)
Boolean
b)
If
c)
elif
d)
else
2.
Which is the correct syntax?
a)
has_dog = true
b)
has_dog = True
c)
has_dog = Treu
d)
HAS_DOG = tRue
3.
What is syntax?
a)
It's a string
b)
It's an exercise
c)
It's a structure
d)
It's a method
4.
Which passes a Boolean to a String?
a)
print "has_dog"
b)
str(has_dog)
c)
print "has_dog" str
d)
(input)(has_dog)
5.
The choices of an if statement are called:
a)
twigs
b)
branches
c)
leaves
d)
trees
6.
An if statement must evaluate to:
a)
Right or Wrong
b)
True
c)
True or False
d)
False
7.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
8.
This operator means that one value is not equal to another value
a)
==
b)
<=
c)
>=
d)
!=
9.
The result of this program:
Friday = False
if Friday:

    print "Jeans day!"
else:
    print "Dress code"
a)
Jeans Day
b)
Jeans day
c)
Dress code
d)
Dress Code
10.
What is the result of the code:
team = Cowboys
if team = Cowboys:
    print "Dallas is #1"
a)
Error
b)
Cowboys
c)
Team
d)
Dallas is #1