Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Conditional Statements Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.
What keyword would you use to add an alternative condition to an if statement?
a)
else if
b)
elseif
c)
elif
d)
None of the above
2.
What will be the output of the following code snippet? x = 10 if x > 5: print("x is greater than 5")
a)
x is greater than 5
b)
x is less than 5
c)
x is equal than 5
d)
No Output
3.
What is the output of the given below program? if 1 + 3 == 7: print("Hello") else: print("Know Program")
a)
Hello
b)
Know Program
c)
Complied Successfully ,No Output
d)
Error
4.
What will be the output of the following code snippet? x = 5 if x < 3: print("x is less than 3") elif x == 3: print("x is equal to 3") else: print("x is greater than 3")
a)
x is less than 3
b)
x is equal than 3
c)
x is greater than 3
d)
No Output
5.
How can you execute multiple statements under a single if block in Python?
a)
Separate statements with a semicolon
b)
Indent the statements to the same level
c)
Use the and keyword between statements
d)
Use the elif keyword
6.
What signifies the end of a statement block or suite in Python?
a)
A comment
b)
}
c)
A line that is indented less than the previous line
d)
end
7.
7.Which one of the following is a valid Python if statement.
a)
f a>=2 :
b)
if (a >= 2)
c)
c) if (a => 22)
d)
if a >= 22
8.
What is the output of the given below program? a = 25 if a > 15: print("Hi") if a <= 30: print("Hello") else: print("Know Program")
a)
Hi
b)
Hello
c)
Hii Hello
d)
Hi Know Program
e)
Hello Know Program
9.
What is the output of the given below program? a = 25 if a < 15: print("Hi") if a <= 30: print("Hello") else: print("Know Program")
a)
hii
b)
Hello
c)
Know Program
d)
Compiled Successfully, No Output. View Answer
10.
Find the output of the given Python program? a, b, c = 1, 3, 5 if a > 0: if b < 2: print("Hi") elif c > 3: print("Hello") else: print("Know Program")
a)
Hi
b)
Hello
c)
Know Program
d)
Compiled Successfully, No Output.
11.
What will the following code print? num = -1 if num < 0: print("Negative") else: print("Positive")
a)
Negative
b)
Positive
c)
Error
d)
None
12.
What will the output of the following code be? x = 5 if x > 2: print("A") elif x > 3: print("B") else: print("C")
a)
A
b)
B
c)
C
d)
None
13.
Which of the following will print "Hello" only if x is not 0? x = 0 if x != 0: print("Hello") else: print("Goodbye")
a)
Hello
b)
Goodbye
c)
Error
d)
d) None
14.
What does this code output? score = 85 if score >= 90: print("A") elif score >= 80: print("B") elif score >= 70: print("C") else: print("F")
a)
A
b)
B
c)
C
d)
F
15.
Which of the following correctly demonstrates a nested if statement? x = 10 if x > 0: if x < 20: print("x is positive and less than 20")
a)
x is positive and less than 20
b)
x is negative
c)
Error
d)
None