Completed
Conditional Statements
Questions From This Challenge
Q1mcq1 mark
Which keyword is used to check a condition in Python?
if ✓
when
check
loop
Q2mcq1 mark
What is the correct syntax to end the condition line in an if statement in Python?
colon (:) ✓
semicolon (;)
curly brace ({)
nothing is required
Q3mcq1 mark
In an if-else statement, when does the else block execute?
Only when the if condition evaluates to False ✓
Only when the if condition evaluates to True
Every time, regardless of the if condition
Only when there is a syntax error
Q4mcq1 mark
In an if-elif-else chain, how many blocks can execute for a single run of the chain (assuming no errors)?
At most one block executes ✓
All blocks always execute
Exactly two blocks execute
None of the blocks ever execute
Q5mcq1 mark
What is wrong with the following code snippet?
if x > 5
print("Big")
Missing colon (:) at the end of the if line ✓
Missing parentheses around x > 5
print() is spelled incorrectly
x > 5 is not a valid Python expression
Q6mcq1 mark
Which of these correctly represents a nested condition check (an if inside another if) in Python's structure?
Indenting the inner if block further than the outer if ✓
Placing both if statements on the same line separated by a comma
Using two separate elif blocks
Python does not allow nested if statements
Q7output1 mark
What is the output of the following code?
x = 8
if x % 2 == 0:
print("Even")
Correct output:
EvenQ8output1 mark
What is the output of the following code?
marks = 35
if marks >= 40:
print("Pass")
else:
print("Fail")
Correct output:
FailQ9output1 mark
What is the output of the following code?
grade = 72
if grade >= 90:
print("A")
elif grade >= 75:
print("B")
elif grade >= 60:
print("C")
else:
print("D")
Correct output:
CQ10output1 mark
What is the output of the following code?
a = 15
b = 20
if a > 10:
if b > 15:
print("Both large")
else:
print("Only a large")
else:
print("Neither large")
Correct output:
Both largeQ11output1 mark
What is the output of the following code?
age = 20
has_id = True
if age >= 18 and has_id:
print("Entry allowed")
else:
print("Entry denied")
Correct output:
Entry allowedQ12output1 mark
What is the output of the following code?
temp = 0
if temp > 0:
print("Above freezing")
elif temp == 0:
print("At freezing point")
else:
print("Below freezing")
Correct output:
At freezing pointQ13output1 mark
What is the output of the following code?
day = "Sunday"
if day == "Sunday" or day == "Saturday":
print("Weekend")
else:
print("Weekday")
Correct output:
WeekendQ14output1 mark
What is the output of the following code?
num = -7
if num > 0:
print("Positive")
elif num < 0:
print("Negative")
else:
print("Zero")
Correct output:
NegativeQ15output1 mark
What is the output of the following code?
flag = False
if not flag:
print("Flag is off")
else:
print("Flag is on")
Correct output:
Flag is off