🟢 Boolean MCQs – Detailed Explanations
Q1. Which of the following expressions is True?
● a) 2 > 3 → ❌ False
● b) 3 < 4 → ✅ True
● c) 3 != 3 → ❌ False
● d) 3 > 3 → ❌ False
✅ Answer: b)
Explanation: Only 3 < 4 evaluates to True.
Q2. Which of these expressions is True?
● a) 2 > 3 and 3 < 4 → False and True = ❌ False
● b) 2 > 3 and 3 > 4 → False and False = ❌
False
● c) 2 < 3 and 3 > 4 → True and False = ❌ False
● d) 2 < 3 and 3 < 4 → ✅ True and True = ✅ True
✅ Answer: d)
Q3. Which expression is True?
● b) 2 < 3 or 3 < 4 → ✅ At least one condition True.
✅ Answer: b)
Explanation: Logical or returns True if at least one condition
is True.
Q4. Which is False?
● a) bool(0) → ❌ False
● b) bool(9) → ✅ True
● c) bool(-9) → ✅ True
● d) bool(9.0) → ✅ True
✅ Answer: a)
Explanation: Only 0 evaluates to False in Boolean
context.
Q5. print(2 and 3)
Returns 3.
Explanation: and returns last operand if all are
True.
✅ Answer: b)
Q6. print(2 and 0)
Returns 0.
Explanation: and stops at first False (0 is False in
Boolean).
✅ Answer: b)
Q8. print(2 and -2)
Both non-zero → returns last value
-2.
✅ Answer: b)
Q9. print(2 or 3)
Returns 2 (first truthy value
in or).
✅ Answer: a)
Q10. print(2 or 0)
Returns 2.
✅ Answer: a)
Q11. print(0 or 2)
Returns 2 (0 is False, moves to second
value).
✅ Answer: a)
Q12. print(2 or 2<3)
Returns 2.
Explanation: First value is truthy, so it stops
there.
✅ Answer: a)
Q13. print(2<3 or 2)
Returns True.
Explanation: 2<3 is evaluated first →
True
✅ Answer: c)
Q14. print(2 and 2<3)
Returns True
Explanation: 2 is truthy, evaluates 2<3 →
True
✅ Answer: c)
Q15. print(2<3 and 2)
Returns 2
Explanation: 2<3 is True → second value is
returned
✅ Answer: a)
Q16. print('a' and 'b')
Both are truthy → returns 'b'
✅ Answer: b)
Q17. print('' and 'b')
Empty string → returns ''
✅ Answer: a)
Q18. print('a' and '')
Empty string again → returns
''
✅ Answer: b)
Q19. print('a' or 'b')
Returns 'a' since it's truthy.
✅ Answer: a)
Q20. print('' or 'b')
First is False (empty), returns
'b'.
✅ Answer: b)
Q21. 'p'>='z' or 'p'>='a'
First is False, second is True → whole is
True.
✅ Answer: b)
Q22. 'Amar'>'am'
Uppercase < lowercase → False
✅ Answer: d) 'Amrita' > 'Amar' is
correct.
Q23 & Q24. String comparison
Lexicographic (character by character)
✅ Answer (Q23 & Q24): a) 'force' > 'fort' is
True
Q25. not 5 or not 5<4
not 5 → False
not 5<4 → not False →
True False or True → True
✅ Answer: a)
Q26. 2 < 6 > 4
True and True → ✅
✅ Answer: b)
Q27. 2 < 6 < 14
Both comparisons are True →
✅
✅ Answer: d)
Q28. 3 > 2 > -2
Both conditions True →
✅
✅ Answer: a)
Q29. 5 <= 11 >= 8
True and True → ✅
✅ Answer: d)
Q30. False and False or not False
→ False or True → ✅ True
✅ Answer: a)
Q31. False or not (False and False)
→ False or not False → False or True → ✅ True
✅ Answer: a)
Q32. True and not False or not True
→ True and True or False → True or False → ✅
True
✅ Answer: c)
Q33. num1 == num2 checks
equality
✅ Answer: b)
Q34. num2 % num1 == 0 → Checks if num1 divides
num2
✅ Answer: d)
Q35. num1 % num2 == 0 → Checks if num1 is multiple of
num2
✅ Answer: c)
Q36. num1 % 3 == 0 or num1 % 5 == 0
✅ Answer: c)
Q37. 0 <= ch <= 9 — checks if integer is
digit
✅ Answer: c)
Q38. '0' <= ch <= '9' — checks if character is
digit
✅ Answer: c)
Q39. PR<10 or TE<23 or PR+TE<33 — directly from
question
✅ Answer: c)
Q40. ENG > 50 and (MTH > 60 or PHY > 60)
✅ Answer: b)
Q41. All pairs must sum > third → use and
✅ Answer: b)
Q42. Two-digit starts with 3 → 30–39; Three-digit ends in 5 → %10==5
✅ Answer: d)
Q43. Two-digit even number
✅ Answer: a)
Q44. Lowercase consonant
✅ Answer: d)
Q45. v == 'AEIOU' checks for exact
match
✅ Answer: d)
Q46. ch in 'aeiou' or p in '0123456789'
✅ Answer: c)
Q47. a > 0 and b > 0 and c > 0 and a+b+c == 180
✅ Answer: a)
Q48. a > b > c or a < b < c – checks ascending or descending
✅ Answer: c)
Q49. (x % y == 0 or y % x == 0) and x != y
✅ Answer: b)
Q50. x % y == 0 and y % x == 0 only if x ==
y
✅ Answer: c)
🟡 Finding Outputs – Detailed Explanations
Q1.
a, b = 1, 2
a += b # a = 1 + 2 = 3
b += a * b # b = 2 + 3 * 2 = 2
+ 6 = 8 print(a, b)
✅ Output: 3 8
Q2.
a=b=5
a += b + 2 # a = 5 + 5 +
2 = 12
b = a * b # b = 12 * 5
= 60 print(a, b)
✅ Output: 12 60
Q3.
p, q = 14, 9
p %= q # p = 14 % 9
=5
q //= p # q = 9 // 5
= 1 print(p, q)
✅ Output: 5 1
Q4.
a, b = 10, 3
c = a % b # c = 10 % 3 = 1
a += b % c # b % c = 3 % 1 = 0 ⇒ a = 10 +
0 = 10
b += a + b // c # b = 3 + 10 + 3 // 1 = 3 +
10 + 3 = 16
print(a, b, c)
✅ Output: 10 16 1
Q5.
a, b = 4,
1 #c=4-1
c=a- =3
ba +=
+= a % b#+a b=%
4 c+ #
1 b=1+5%1+1%3=1
+0+1==
b 2 5
print(a, b, c)
✅ Output: 5 2 3
Q6.
a, b = 10,
3 # c = 2 ** 3
c=
a +=2b****
b (c=// 8a) # c // a = 8 // 10 = 0 ⇒ b ** 0 = 1 ⇒ a =
10 + 1 = 11
b //= a + b // c # b = 3 // (11 + 3
// 8) = 3 // 11 = 0 print(a, b, c, sep="#")
✅ Output: 11#0#8
Q7.
a = 83
b = a % 10 + a // # b = 3 + 8
10 = 11
c=b%
a + c10 + b //# a#=c11 =+
1+21
10
= 13 = 2
print(a, b, c, sep=", ", end=".\
n")
✅ Output: 13, 11, 2.
Q8.
a, b = -1, 3
c=a%b # -1 % 3 = 2
a += b % c # a = -1 + 3 % 2 = -1 + 1 = 0
b += a % b % # b = 3 + 0 % 3 % -2 = 3 +
(-c)
print(a, b, c, 0=3
end="#")
✅ Output: 0 3 2#
Q9.
a, b, c = 5, 10,
15 # a = 5 + 5 + 10 + 15 =
a += a + b + c 35
b += a + b + c # b = 10 + 35 + 10 + 15
c += a + b = 70
+ c print(a, # c = 15 + 35 + 70 + 15
b, c) = 135
✅ Output: 35 70 135
Q10.
a, b, c = 5, 10,
15 # b = 10 + 5 + 10 +
b += a + b + c 15 = 40
c += a + b # c = 15 + 5 + 40 + 15
+ c a += a = 75
+ b + c # a = 5 + 5 + 40 + 75
print(a, b, c) = 125
✅ Output: 125 40 75
Q11.
a, b, c = 5, 10,
15 # c = 15 + 5 + 10 + 15 =
c += a + b + c 45
a += a + b + c # a = 5 + 5 + 10 + 45 =
b += a + b 65
+ c print(a, # b = 10 + 65 + 10 + 45
b, c) = 130
✅ Output: 65 130 45
Q12.
a, b, c = 1,
2, 3 # a = 1 * (1 + 2) =
a *= a + b 3
b *= a + b # b = 2 * (3 + 2)
c *= a + b = 10
print(a, b, # c = 3 * (3 + 10)
c) = 39
✅ Output: 3 10 39
Q13.
a, b, c = 1,
2, 3 # b = 2 * (1 + 2)
b *= a + b =6
c += a #c=3+1+6
+ba= = 10
+b * c # a = +6 * 10 =
60
print(a, b, c)
✅ Output: 60 6 10
Q14.
a, b, c = 10,
7,//=
b 5 b // # b = 7 // (7 // 5 = 1) → 7
c a %= a # a = 10 % (10 % 7 = 3) → 10 %
% b c *= 3=1
c*a # c = 5 * 5 * 1 = 25
print(a, b,
c)
✅ Output: 1 7 25
Q15.
a, b, c = 10,
7, 5 # a = 10 % 4
a %= 4 =2
b %= a # cb =
=57%
%12=
c %= b 1
=0
print(a, b,
c)
✅ Output: 2 1 0
🟠 List MCQs – Detailed Explanations
Q1. [alpha for alpha in range(7)]
Generates a list of values from 0 to 6 (inclusive start,
exclusive end).
✅ Answer: d) [0,1,2,3,4,5,6]
Q2. [k+2 for k in range(7)]
Add 2 to each number from 0 to 6:
→ [0+2, 1+2, ..., 6+2] =
[2,3,4,5,6,7,8]
✅ Answer: a) [2,3,4,5,6,7,8]
Q3. [k*2 for k in range(2,7)]
Multiply each number from 2 to 6 by 2:
→ [2*2, 3*2, 4*2, 5*2, 6*2] =
[4,6,8,10,12]
✅ Answer: b) [4,6,8,10,12]
Q4. [k-2 for k in range(2,7)]
Subtract 2 from numbers 2 to 6:
→ [0,1,2,3,4]
✅ Answer: c) [0,1,2,3,4]
Q5. [2*k - 1 for k in range(2,8,2)]
k values: 2, 4, 6
Expression: 2*2-1=3, 2*4-1=7, 2*6-1=11
✅ Answer: b) [3,7,11]
Q6. [3]*4
Repeats 3 four times
✅ Answer: b) [3,3,3,3]
Q7. [3]*len([3])
len([3]) = 1 → [3]*1 =
[3]
✅ Answer: b) [3]
Q8. []*4
Empty list times anything =
empty list
✅ Answer: a) [ ]
Q9. [None]*4
Creates a list with 4 Nones
✅ Answer: c) [None, None, None, None]
Q10. [None]*3 + [4]*3
First part → [None, None, None], second →
[4,4,4]
Combined = [None, None, None, 4, 4, 4]
✅ Answer: a) [None, None, None, 4, 4, 4]
Q11. If A=[5,3,8], B=[A,8,66,45]
● A in B → ✅ A is a sublist inside B
● [A] in B → ❌ [A] is not an
element
● B in A and [B] in A → ❌
✅ Answer: a)
Q12. A=[5,3,8] and B=[5,8,3]
Equal values but different order
→ A == B → ❌
Lexicographic comparison: 3 < 8, so A < B
→✅
✅ Answer: b)
Q13. A = list('madhur'), B = list('Madhuri')
● First elements: 'm' > 'M' (lowercase > uppercase)
→ So A > B → ✅
✅ Answer: c)
Q14. A = list(range(5)), B = list(range(1,4))
→ A = [0,1,2,3,4], B = [1,2,3]
Since 0 < 1 → A < B
✅ Answer: a)
Q15. A = list(range(5)), B = list(range(len(A)))
→ Both become [0,1,2,3,4]
✅ Answer: a) A == B
Q16. A = [2,3,7,6,[3,5,8],5,7]
a) A[1:] gives a list → [3,7,6,[3,5,8],5,7]
then [2:][1:][2:] — illegal on non-list
→ All these use chaining on result lists which
isn’t valid
✅ Answer: All options are invalid
Best pick: a) is clearly invalid.
Q17. A[1:]=3 is invalid
You can assign a list to a slice, but not a single
value.
✅ Answer: c)
Q18. Insert (not overwrite) 4 at index 0
→ [Link](0,4)
✅ Answer: c)
Q19. Which increases length of A?
a)A[0]=0 → overwrite
b)A[0]=[0] → still 1 element
c)A[0]=0, → tuple assigned — no increase
d)A[:0]=[0] → inserts at beginning → increases
length ✅
✅ Answer: d)
Q20. Which decreases length of A?
a)A[5:] = [5,6] → overwrite end → no change
b)A[:5]=[5,6] → shrink first 5 → ✅ decreases size
c)A[::5] = [5,6] → step assignment, complex but not
deletion
d)A[5]=[5,6] → assign a list at index 5 → no change in
length
✅ Answer: b)
🟣 Tuple MCQs – Detailed Explanations
Q1. Which of the following will create a tuple?
● a) a = 1 → ❌ int
● b) a = 1, → ✅ Tuple with one element (comma is
necessary)
● c) a = (1) → ❌ Just int in brackets
● d) a = tuple(1) → ❌ 1 is not iterable → TypeError
✅ Answer: b)
Q2. Which will not create a tuple?
● a) a = 1,2,3 → ✅ Tuple
● b) b = ([1,2,3]) → ❌ List inside brackets =
list
● c) c = (1,2,3) → ✅ Tuple
● d) d = tuple('tuple') → ✅ Tuple of
characters
✅ Answer: b)
Q3. Which variable will NOT be a tuple?
a= # Tuple
1,2,3,4,5,6 # Tuple with one item
b = a[1], # c = 3, d = 4 — not
c,d = tuples # Tuple (5,6)
a[2],a[3]
e = a[4],a[5]
✅ Answer: c)
Explanation: c and d are individual elements (int), not
tuples.
Q4. Which of these is correct?
● a) ❌ Tuples are immutable, lists are not
● b) ✅ Tuples → immutable, Lists → mutable
● c) ❌ Both are mutable – wrong
● d) ❌ Tuples are immutable – correct, but lists are not
immutable
✅ Answer: b)
Q5. Which statements are correct?
● a) ✅ Tuple + Tuple → Valid
● b) ❌ List + Tuple → Error
● c) ❌ Tuple + List → Error
● d) ✅ List + List → Valid
✅ Answer: a) and d)
Q6. If A = tuple([3,6,7]), B = list(A)
● a) A += B → Error (can’t concatenate list to tuple)
● b) B += A → ✅ List + Tuple = Valid (list supports += with any
iterable)
● c) A + B → ❌ TypeError
● d) B + A → ✅ List + Tuple = Valid (list accepts any iterable via
+)
✅ Answer: b) and d)
Q7. A = 1,2,3,4,5 is a tuple
● a) A[1] = 1 → ❌ Tuples are immutable
● b) A += 1 → ❌ Can only add another tuple
● c) [Link]() → ❌ No pop() for tuples
● d) A = A[1:] → ✅ Valid — creates a new
tuple
✅ Answer: d)
Q8. a = ('ant','bat','cat')
● a) [Link]('rat') → ✅ Valid, returns 0
● b) [Link]('cat') → ❌ append() not allowed
● c) a += ('dog') → ❌ No comma → treated as string →
error
● d) a += ('dog',) → ✅ Correct way to add item
✅ Answer: a) and d)
Q9. a = (1,2), b = ['a','b']
● a) a + [b] → ❌ TypeError
● b) [a] + [b] → ✅ Valid list addition
● c) a + (b) → ❌ b is a list, not tuple
● d) a + (b,) → ✅ b is placed as one element (a tuple
of list)
✅ Answer: b) and d)
Q10. a = (1,2,3,[4,5,6],7,8)
● a) len(a[2]) → ❌ a[2] is 3 → len(3) invalid
● b) a[3] = 5 → ❌ Tuples are immutable
● c) a[3][1] = 2 → ✅ a[3] is a mutable list inside tuple →
valid
● d) len(a[3]) = 3 → ❌ Can’t assign to len()
✅ Answer: c)
Q11. a = [1,2,3,(4,5,6),7,8]
● a) len(a[2]) → ❌ a[2] = 3 (int) → error
● b) a[3] = 5 → ✅ List is mutable
● c) a[3][1] = 2 → ❌ Tuples are immutable
● d) len(a[3]) = 3 → ❌ Can't assign to
len()
✅ Answer: b)
Q12. A = 'beautiful',
Trailing comma → makes it
tuple
✅ Answer: a) 1
Q13. A = ('beautiful',)
Again, trailing comma → tuple with
1 item
✅ Answer: a) 1
Q14. A = tuple('beautiful')
→ Creates tuple of characters → 9
characters
✅ Answer: c) 9
Q15. A = tuple('beautiful',)
❌ TypeError — only 1 argument allowed
✅ Answer: d) The statement is not correct
Q16. A = tuple('beautiful'),
Tuple with one element (a tuple of a tuple of
characters)
✅ Answer: a) 1
Q17. A = tuple(range(5))
→ Tuple: (0,1,2,3,4) → 5
elements
✅ Answer: c) 5
Q18. A = tuple(range(5)),
Tuple containing a tuple → 1
element
✅ Answer: a) 1
Q19. A = tuple(3,5,8)
Invalid — tuple expects 1
argument
✅ Answer: d)
Q20. A = tuple('hello'), list('Hello')
Tuple and list → combined into a tuple of 2 elements
✅ Answer: b) 2
🟤 Dictionary MCQs – Detailed Solutions
Q1. Which of the following statements is/are correct?
● a) ❌ Dictionaries are mutable, not immutable.
● b) ❌ A dictionary must have key–value pairs; keys alone are not allowed.
● c) ❌ Keys can be of different types.
● d) ✅ Correct. Keys must be of immutable types (like int, str, tuple).
✅ Answer: d)
Explanation: In Python, keys must be hashable and hence immutable types like
int, str,
tuple, etc.
Q2. Which of the following cannot be a key of a dictionary?
● a) ✅ 5 is an int — valid key.
● b) ✅ '5' is a str — valid key.
● c) ❌ [5] is a list — invalid, as lists are mutable.
● d) ✅ (5,) is a tuple — valid key.
✅ Answer: c)
Explanation: Keys must be immutable. Lists are mutable, so they can't be
dictionary keys.
Q3. The values in a dictionary:
● a) ❌ Not just strings.
● b) ❌ Values can be mutable or immutable.
● c) ❌ Same reason.
● d) ✅ Correct – Values can be of any type.
✅ Answer: d)
Explanation: Python dictionaries allow values of any data type: numbers, strings,
lists, even another dictionary.
Q4. Dictionary elements can be accessed using:
● a) ❌ Indexing is for lists, not dictionaries.
● b) ✅ Correct.
● c) ❌ Values cannot be used to access elements.
● d) ❌ Only keys can be used, not index/values.
✅ Answer: b)
Explanation: Dictionary elements are accessed only by their
keys.
Q5. Which of the following statements is/are correct?
● a) ❌ Duplicate keys are not allowed in
dictionaries.
● b) ✅ Allowed — same values with different
keys.
● c) ❌ Duplicate keys get overwritten.
● d) ✅ Valid.
✅ Answer: b) and d)
Explanation: Keys must be unique, but values can be
duplicated.
Q6. Which of the following statements will create a dictionary?
● a) ✅ Correct format.
● b) ❌ Tuple syntax, not valid for dict.
● c) ❌ List syntax, not valid for dict.
● d) ❌ Just key–value format without a dict object.
✅ Answer: a)
Explanation: Proper dictionary syntax is {key: value}.
Q7. Which of the following methods takes any iterable as a parameter?
● a) ❌ update() takes another dictionary or iterable of pairs.
● b) ❌ clear() removes all elements — no parameter.
● c) ❌ key() is not a method.
● d) ✅ Correct — fromkeys() creates a dictionary from any
iterable.
✅ Answer: d)
Explanation: [Link](iterable, value) creates a new
dictionary.
Q8. Which among these will return a valid dictionary?
● All options use valid iterables.
● a), b), c) all are correct.
✅ Answer: d)
Explanation: All three are valid uses of
fromkeys().
Q9. Which of the following will create a dictionary?
● a) ❌ 123 is an int, not iterable.
● b) ❌ Invalid syntax.
● c) ❌ Invalid key-value structure.
● d) ✅ Correct.
✅ Answer: d)
Explanation: [Link]('123','abc') maps each character in '123' to
'abc'.
Q10. d={1:"One",2:"Two"} → len(d) = ?
● There are two key–value pairs.
✅ Answer: b)
Explanation: len() returns number of key–value
pairs.
Q11. [Link](d), [Link](), [Link]() — which create a dictionary?
● a) ✅ Keys become keys, values default to None.
● b) ✅ Same as above.
● c) ✅ But values are used as keys here.
✅ Answer: d) All of these
Explanation: fromkeys() accepts any iterable.
Q12. Which of the following are True?
● a) ✅ Key 1 exists.
● b) ✅ Key 2 exists.
● c) ❌ "One" is a value.
● d) ❌ Same reason.
✅ Answer: a) and b)
Explanation: in checks keys, not
values.
Q13. Which expressions raise an exception?
● a) ✅ Deletes key 1 — valid.
● b) ❌ KeyError! "Two" is a value, not key.
● c) ✅ Deletes whole dictionary — valid.
● d) ❌ Option b raises an exception.
✅ Answer: b)
Explanation: Only values can’t be deleted via del
d[value].
Q14. Which method deletes the last inserted element?
● a) ❌ pop() removes a specified key.
● b) ✅ popitem() removes last inserted key–value
pair.
● c) ❌ remove() is for lists.
● d) ❌ clear() removes all items.
✅ Answer: b)
Explanation: popitem() deletes the most recently added key-
value pair.
Q15. a={1:2,3:4,5:6}.popitem() → what is value of a?
● Removes last item → {5:6} → result: {1:2, 3:4}
✅ Answer: b)
Explanation: popitem() modifies dictionary in-place.
Q16. Which method will raise exception if no argument is given?
● a) ✅ pop() requires a key if dictionary is empty.
● b) ❌ clear() works without arguments.
● c) ❌ copy() also does.
● d) ❌ setdefault() can take default value.
✅ Answer: a)
Explanation: pop() without arguments → error if empty.
Q17. Which method returns a tuple?
● d) ✅ popitem() returns (key, value).
✅ Answer: d)
Explanation: popitem() always returns a tuple from
the dict.
Q18. Which is not a dictionary method?
● a) ❌ del is not a method — it’s a
keyword.
● b), c), d) — All valid methods.
✅ Answer: a)
Explanation: del is a keyword, not a
method.
Q19. Which statement is invalid?
● All are valid — nothing wrong syntactically.
✅ Answer: d)
Explanation: All given statements are valid, so "None of these" is the
answer.
Q20. Which expression will raise exception in an empty dictionary?
● a) ❌ get() returns None.
● b) ❌ setdefault() adds the key.
● c) ✅ pop() raises KeyError if no key.
● d) ❌ del d is fine.
✅ Answer: c)
Explanation: pop() on an empty dictionary without arguments will raise
an error.