Completed
Python Fundamentals & Control Flow
Questions From This Challenge
Q1output1 mark
What will be the output of the following Python code?
x = 18 x += 4 * 3 x //= 5 x -= 2 print(x)
Correct output:
4Q2mcq1 mark
Which of the following expressions evaluates to 17?
5 + 3 * 4 ✓
(5 + 3) * 2
20 - 3 ** 2
30 // 2 + 3
Q3output1 mark
What will be the output of the following Python code?
x = 10 > 3 and 10 % 3 == 1 or 3 == 3 and 10 < 5 print(x)
Correct output:
TrueQ4mcq1 mark
Which of the following statements about Python operator precedence is correct?
+ is evaluated before *
* is evaluated before **
** is evaluated before * ✓
// is always evaluated after +
Q5output1 mark
What will be the output of the following Python code?
a = input("Enter first number: ")
b = input("Enter second number: ")
print(int(a) + int(b))
print(a + b)
If the user enters:
12
8
Correct output:
20
128Q6output1 mark
What will be the output of the following Python code?
x = 7 y = 2 x = x / y print(type(x).__name__) print(x)
Correct output:
float
3.5Q7mcq1 mark
What type of error occurs when the following statement is executed? x = 10 if x > 5 print(x)
Logical error
Runtime error
Syntax error ✓
No error
Q8output1 mark
What will be the output of the following Python code?
x = 15
if x % 3 == 0:
x = x // 3
if x % 2 == 0:
x = x + 5
else:
x = x - 5
print(x)
Correct output:
10Q9output1 mark
What will be the output of the following Python code?
n = 17
if n % 2 == 0:
print("A")
elif n % 3 == 0:
print("B")
elif n % 5 == 0:
print("C")
else:
print("D")
Correct output:
DQ10output1 mark
What will be the output of the following Python code?
total = 0
for i in range(2, 11, 2):
if i % 4 == 0:
continue
total = total + i
print(total)
Correct output:
18Q11mcq1 mark
Which statement correctly describes the effect of break in the following loop? for i in range(3, 10): if i > 6: break print(i)
It skips only the current iteration.
It terminates the loop completely. ✓
It restarts the loop from the beginning.
It terminates the entire Python program.
Q12output1 mark
What will be the output of the following Python code?
n = 29
count = 0
while n > 5:
if n % 2 == 0:
n = n // 2
else:
n = n - 5
count = count + 1
if n <= 3:
break
print(n)
print(count)
Correct output:
3
4Q13output1 mark
What will be the output of the following Python code?
x = 1
for i in range(1, 8):
if i == 3:
continue
if i == 6:
break
x = x * i
print(x)
Correct output:
40Q14mcq1 mark
Which statement about the identity operator is correct?
"is" checks whether two values are equal.
"is" checks whether two references refer to the same object. ✓
"is" is a membership operator.
"is not" can only be used with strings.
Q15output1 mark
What will be the output of the following Python code?
n = 1
total = 0
while n <= 10:
n = n + 2
if n % 3 == 0:
continue
total = total + n
if total > 15:
break
print(n)
print(total)
Correct output:
11
23