Problem Solving Using Programming MCQs

Topic-wise practice questions for Problem Solving & Analytical Skills. Test your knowledge, check solutions on demand, and pace your preparation.

Zero-leak answer engine • Rate-limited explanations
Practice in Timed Mode
Q1medium
Trace the logic:

x = [1, 2, 3]
y = x
y[0] = 99
print(x[0])
Assuming x and y are reference types (like in Python or JS):
Q2hard
A function calculateDiscount(price) is supposed to return the final price. However, it also prints "Success!" to the console and saves the price to a history.txt file. These extra actions are called:
Q3easy
What is the output?

val = 1
for i from 1 to 3:
    val = val * i
print(val)
Q4medium
You are writing a program for a library. You have copied the same 10 lines of "Late Fee Calculation" logic into five different parts of your code. Which programming principle are you violating?
Q5medium
You are writing a program that handles sensitive bank transactions. You want to ensure that even if an error occurs mid-transaction, the system doesn't leave the bank account in a corrupted state. Which structure is most important?
Q6medium
Why is "Hard-coding" values like tax = 0.17 directly into your functions considered a bad practice?
Q7easy
What does "Refactoring" code mean?
Q8medium
What will be the output of this code snippet?

total = 0
for i from 1 to 5:
    if (i % 2 == 0):
        total = total + i
print(total)
Q9medium
Why is using "Global Variables" generally considered a poor practice in large-scale problem solving?
Q10hard
A developer is writing a program to calculate the average of three numbers. Find the logical bug:

num1 = 10
num2 = 20
num3 = 30
average = num1 + num2 + num3 / 3