intensepracticeacademy.com

Free Python MCQ questions

Free Python MCQ Questions 2025 (With Answers & Explanations)

Practice Free Python MCQ Questions with answers and clear explanations, designed for campus placements, coding interviews, online tests and IT job assessments. All questions are created by Intense Practice Academy based on the latest exam patterns.

How to Use This Free Python MCQ Page:

✔ Read each Python question carefully.

✔ Try to answer without seeing the solution.

✔ Click “View Answer & Explanation” to understand the concept fully.

Topics Covered in This Free Python MCQ Quiz

  • ✔ Python basics & syntax
  • ✔ Data types – int, float, bool, str
  • ✔ Lists, tuples, dictionaries and sets
  • if-else, loops (for, while)
  • ✔ Functions & default arguments
  • ✔ List comprehensions
  • ✔ Strings & slicing
  • ✔ OOP (classes, objects)
  • ✔ Exception handling & file handling (basic)

Free Python MCQ Questions – Practice Set

Q1. What is the output of the following code?

x = 5
y = 2
print(x // y)
  • A) 2.5
  • B) 2
  • C) 3
  • D) 2.0
View Answer & Explanation

Answer: B) 2

// is the floor division operator in Python. 5 / 2 is 2.5, and the floor value is 2. So x // y prints 2.

Q2. Which of the following is a valid way to create a list in Python?

  • A) list = (1, 2, 3)
  • B) list = [1, 2, 3]
  • C) list = {1, 2, 3}
  • D) list = <1, 2, 3>
View Answer & Explanation

Answer: B) list = [1, 2, 3]

Lists in Python are created using square brackets []. Round brackets () create tuples, curly braces {} create sets or dictionaries.

Q3. What is the data type of x in the following code?

x = "10"
  • A) int
  • B) float
  • C) str
  • D) bool
View Answer & Explanation

Answer: C) str

The value is inside quotes, so it is a string. To convert it into an integer, we would use int("10").

Q4. What will be the output of the following code?

numbers = [1, 2, 3]
numbers.append([4, 5])
print(len(numbers))
  • A) 3
  • B) 4
  • C) 5
  • D) 6
View Answer & Explanation

Answer: B) 4

append() adds the given object as a single element. After append([4, 5]), list becomes [1, 2, 3, [4, 5]]. So its length is 4.

Q5. Which of the following statements about tuples is TRUE?

  • A) Tuples are mutable and lists are immutable.
  • B) Both tuples and lists are mutable.
  • C) Tuples are immutable and lists are mutable.
  • D) Both tuples and lists are immutable.
View Answer & Explanation

Answer: C) Tuples are immutable and lists are mutable.

Once created, a tuple cannot be changed (immutable), while a list can be modified by adding, removing or updating elements.

Q6. What will be the output of the code below?

for i in range(2, 7, 2):
    print(i, end=" ")
  • A) 2 3 4 5 6
  • B) 2 4 6
  • C) 3 5 7
  • D) 2 4 6 8
View Answer & Explanation

Answer: B) 2 4 6

range(2, 7, 2) starts at 2, stops before 7 and steps by 2. The sequence is 2, 4, 6.

Q7. Which keyword is used to define a function in Python?

  • A) fun
  • B) def
  • C) function
  • D) lambda
View Answer & Explanation

Answer: B) def

We define normal functions using the def keyword. lambda is used to create small anonymous functions.

Q8. What will be the output of this code?

def add(a, b=2):
    return a + b

print(add(3))
  • A) 2
  • B) 3
  • C) 5
  • D) Error
View Answer & Explanation

Answer: C) 5

b has a default value 2. When we call add(3), a = 3 and b = 2. So result is 3 + 2 = 5.

Q9. Which of the following creates a set in Python?

  • A) my_set = []
  • B) my_set = ()
  • C) my_set = {1, 2, 3}
  • D) my_set = dict()
View Answer & Explanation

Answer: C) my_set = {1, 2, 3}

Curly braces with comma-separated elements create a set. [] is a list, () is a tuple and dict() creates an empty dictionary.

Q10. What will this code print?

s = "Python"
print(s[1:4])
  • A) Pyt
  • B) yth
  • C) ytho
  • D) Pyth
View Answer & Explanation

Answer: B) yth

Slicing s[1:4] starts from index 1 (inclusive) and goes up to index 4 (exclusive). For "Python", indices are: 0:P, 1:y, 2:t, 3:h, 4:o, 5:n. So the substring is "yth".

🎯 Want More Python MCQs for Exams & Interviews?

Move from this free practice set to our Python MCQ Pack 2025 on Intense Practice Academy:

  • • 500+ Python questions from basics to advanced
  • • Output-based & tricky logic MCQs
  • • Detailed explanations for every question
  • • Perfect for campus placements & coding tests

Pack Prices:

  • 💻 Java MCQ Pack 2025 – ₹369
  • 💻 C MCQ Pack 2025 – ₹299
  • 💻 Python MCQ Pack 2025 – ₹299

👉 Login to get all MCQ packs & mock tests:
mocktest.intensepracticeacademy.com

Login & Unlock MCQ Packs

Q11. Which expression correctly checks if key "name" exists in dictionary d?

d = {"name": "Arun", "age": 22}
  • A) "name" in d
  • B) d.has("name")
  • C) "name" in d.values()
  • D) exists(d, "name")
View Answer & Explanation

Answer: A) "name" in d

The expression key in dictionary checks whether a key is present. Option C checks among values, and B, D are not valid dictionary methods.

Q12. What is the result of the following list comprehension?

result = [x * x for x in range(1, 4)]
print(result)
  • A) [1, 2, 3, 4]
  • B) [1, 4, 9]
  • C) [0, 1, 4]
  • D) [1, 8, 27]
View Answer & Explanation

Answer: B) [1, 4, 9]

range(1, 4) gives 1, 2, 3. Squaring each: 1*1=1, 2*2=4, 3*3=9.

Q13. What will the following code print?

class Test:
    count = 0

    def __init__(self):
        Test.count += 1

obj1 = Test()
obj2 = Test()
print(Test.count)
  • A) 0
  • B) 1
  • C) 2
  • D) Error
View Answer & Explanation

Answer: C) 2

count is a class variable. Each time an object is created, the constructor increments it by 1. Two objects → count = 2.

Q14. Which exception is raised when you access a list index that does not exist?

  • A) KeyError
  • B) IndexError
  • C) TypeError
  • D) ValueError
View Answer & Explanation

Answer: B) IndexError

IndexError occurs when we try to access an index outside the valid range for a sequence (like a list or string).

Q15. Which syntax is correct for handling an exception in Python?

  • A) try: ... except: ... end
  • B) try: ... catch: ...
  • C) try: ... except Exception as e: ...
  • D) handle: ... exception ...
View Answer & Explanation

Answer: C) try: ... except Exception as e: ...

Python uses try and except for exception handling. The pattern try: ... except Exception as e: catches exceptions and assigns them to variable e.

Q16. What will be the output of this code?

a = [1, 2, 3]
b = a
b.append(4)
print(a)
  • A) [1, 2, 3]
  • B) [1, 2, 3, 4]
  • C) [4, 1, 2, 3]
  • D) Error
View Answer & Explanation

Answer: B) [1, 2, 3, 4]

a and b refer to the same list object. Changing b also changes a.

Q17. Which method removes and returns the last element from a list?

  • A) remove()
  • B) pop()
  • C) discard()
  • D) delete()
View Answer & Explanation

Answer: B) pop()

pop() removes and returns the last item by default. remove() deletes a value, discard() is for sets, and delete() is not a list method.

Q18. What is the output of this code?

x = [1, 2, 3]
y = x[:]
y.append(4)
print(len(x), len(y))
  • A) 3 3
  • B) 3 4
  • C) 4 4
  • D) 4 3
View Answer & Explanation

Answer: B) 3 4

x[:] creates a shallow copy of the list. x remains length 3, y becomes length 4.

Q19. Which keyword is used to create an anonymous function in Python?

  • A) anon
  • B) lambda
  • C) func
  • D) def
View Answer & Explanation

Answer: B) lambda

lambda creates small anonymous functions. def is used for normal named functions.

Q20. What does this code print?

nums = [1, 2, 3, 4]
print(nums[-2])
  • A) 1
  • B) 2
  • C) 3
  • D) 4
View Answer & Explanation

Answer: C) 3

Negative indices count from the end. -1 → last element (4), -2 → second last (3).


What to Do Next?

✅ Practice these Python MCQs multiple times.
✅ Mark the questions you got wrong and revise those concepts.
✅ Share this free page with friends preparing for placements and coding tests.

More Free Practice from Intense Practice Academy:


FAQs – Free Python MCQ Questions

1. Who can use this free Python MCQ page?

This page is suitable for B.E/B.Tech, B.Sc, BCA, MCA students, diploma students and freshers preparing for campus placements, coding interviews and online Python skill tests.

2. Are these Python MCQs enough for clearing campus placements?

These free MCQs give you a strong foundation in important Python concepts. For full coverage, more output-based and tricky questions, you can use our Python MCQ Pack 2025 available on our test portal.

3. How should I practice these Python questions?

First, try to solve without seeing the answer. Then open “View Answer & Explanation” and understand:

  • ✔ Why the correct option is right
  • ✔ Why other options are wrong
  • ✔ Which Python concept is being tested

4. Are there free MCQ pages for Java and C also?

Yes. Intense Practice Academy also provides:

5. How can I get full Java, C and Python MCQ packs?

You can unlock all our MCQ packs and mock tests by logging in to:

🔗 mocktest.intensepracticeacademy.com

Current pack prices:

  • 💻 Java MCQ Pack 2025 – ₹369
  • 💻 C MCQ Pack 2025 – ₹299
  • 💻 Python MCQ Pack 2025 – ₹299

🚀 Ready to Take Full Mock Tests?

Login to our portal, attempt timed tests, track your scores and improve your performance step by step.

🔗 mocktest.intensepracticeacademy.com

Login & Start Practicing