Completed
Python Fundamentals, Logic & Loop Master Challenge
Questions From This Challenge
Q1output1 mark
What will be the output of the following Python code?
x = 7 y = 3 x += y * 2 y = x - y print(x, y)
Correct output:
13 10Q2mcq1 mark
Which of the following correctly identifies the l-value and r-value in the statement below? x = 25
x is r-value and 25 is l-value
x is l-value and 25 is r-value ✓
Both x and 25 are l-values
Both x and 25 are r-values
Q3output1 mark
What will be the output of the following Python code?
a = 5 b = 10 c = 15 print(a < b and b < c or c < a)
Correct output:
TrueQ4output1 mark
What will be the output of the following Python code?
s = "PYTHON"
print(s[1:5])
print(s[-3:])
print("TH" in s)
Correct output:
YTHO
HON
TrueQ5output1 mark
What will be the output of the following Python code?
x = 2 + 3 * 4 ** 1 y = (x - 5) // 3 print(x, y)
Correct output:
14 3Q6output1 mark
What will be the output of the following Python code?
s = "AB"
print(s * 3 + "C")
print("A" in s and "C" not in s)
Correct output:
ABABABC
TrueQ7output1 mark
What will be the output of the following Python code?
n = 29
if n % 2 == 0:
print("A")
elif n % 3 == 0:
print("B")
elif n % 5 == 0:
print("C")
else:
print("D")
Correct output:
DQ8output1 mark
What will be the output of the following Python code?
total = 0
for i in range(1, 7):
if i == 3:
continue
if i == 6:
break
total += i
print(total)
Correct output:
12Q9output1 mark
What will be the output of the following Python code?
for i in range(2, 5):
for j in range(1, 4):
print(i + j, end=" ")
Correct output:
3 4 5 4 5 6 5 6 7Q10output1 mark
What will be the output of the following Python code?
x = 1
for i in range(1, 5):
x = x * i
if x > 5:
break
print(x, i)
Correct output:
6 3Q11output1 mark
What will be the output of the following Python code?
n = 1
total = 0
while n <= 10:
if n % 3 == 0:
n += 2
continue
total += n
n += 1
print(total)
Correct output:
31Q12mcq1 mark
Which of the following statements will produce the sequence 10, 7, 4, 1 using range()?
range(10, 1, -3)
range(10, 0, -3) ✓
range(10, 1, 3)
range(10, -1, -3)
Q13output1 mark
What will be the output of the following Python code?
s = "COMPUTER"
count = 0
for ch in s:
if ch in "AEIOU":
count += 1
print(count)
Correct output:
3Q14output1 mark
What will be the output of the following Python code?
x = 10
if x > 5:
if x < 8:
print("A")
elif x == 10:
print("B")
else:
print("C")
else:
print("D")
Correct output:
BQ15output1 mark
What will be the output of the following Python code?
s = "PYTHON"
result = ""
for i in range(len(s) - 1, -1, -2):
result += s[i]
print(result)
Correct output:
NHY