Completed
Class 11 CS – Advanced Conditional & Loop Challenge
Questions From This Challenge
Q1output1 mark
What will be the output of the following Python code?
x = 15
if x % 3 == 0:
x = x + 4
if x % 2 == 0:
x = x * 2
else:
x = x - 3
print(x)
Correct output:
16Q2output1 mark
What will be the output of the following Python code?
n = 17
if n > 10:
n = n - 5
elif n > 5:
n = n + 5
else:
n = n * 2
print(n)
Correct output:
12Q3output1 mark
What will be the output of the following Python code?
x = 20
if x > 10:
x = x - 7
if x > 15:
x = x + 3
elif x > 10:
x = x - 3
else:
x = x * 2
print(x)
Correct output:
10Q4output1 mark
What will be the output of the following Python code?
n = 30
if n % 2 == 0:
print("A")
elif n % 3 == 0:
print("B")
else:
print("C")
if n % 5 == 0:
print("D")
else:
print("E")
Correct output:
A
DQ5output1 mark
What will be the output of the following Python code?
marks = 68
if marks >= 80:
grade = "A"
elif marks >= 60:
grade = "B"
elif marks >= 40:
grade = "C"
else:
grade = "D"
print(grade)
Correct output:
BQ6output1 mark
What will be the output of the following Python code?
total = 0
for i in [2, 5, 8, 11]:
if i > 5:
total = total + i
else:
total = total - i
print(total)
Correct output:
12Q7output1 mark
What will be the output of the following Python code?
x = 1
for i in [3, 5, 7]:
x = x + i
if x > 8:
x = x - 2
print(x)
Correct output:
12Q8output1 mark
What will be the output of the following Python code?
total = 0
for i in [4, 7, 10, 13]:
if i % 2 == 0:
total += i
else:
total -= i
print(total)
Correct output:
-6Q9output1 mark
What will be the output of the following Python code?
n = 16
count = 0
while n > 1:
n = n // 2
count += 1
print(count, n)
Correct output:
4 1Q10output1 mark
What will be the output of the following Python code?
x = 5
total = 0
while x < 15:
total += x
x += 3
print(total, x)
Correct output:
38 17Q11output1 mark
What will be the output of the following Python code?
n = 25
total = 0
while n > 5:
if n % 2 == 0:
total += n
else:
total -= n
n -= 4
print(total)
Correct output:
-85Q12output1 mark
What will be the output of the following Python code?
x = 2
while x < 30:
if x % 3 == 0:
x = x + 4
else:
x = x + 5
print(x)
Correct output:
30Q13output1 mark
What will be the output of the following Python code?
total = 0
for i in [1, 2, 3, 4, 5]:
if i % 2 == 0:
total = total + i * 2
else:
total = total + i
print(total)
Correct output:
21Q14output1 mark
What will be the output of the following Python code?
x = 10
if x >= 10:
x = x - 4
if x >= 8:
x = x + 5
elif x >= 5:
x = x + 2
else:
x = x * 2
print(x)
Correct output:
8Q15output1 mark
What will be the output of the following Python code?
n = 3
total = 0
while n <= 15:
if n % 3 == 0:
total += n
else:
total -= n
n += 2
print(total, n)
Correct output:
63 17