Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 113 / 11499%· free preview
Exam Prep1/2

Python Exam Questions

High-yield Python theory + program questions repeatedly asked in B.Tech / college exams.

Overview

Common Python exam questions across theory, programs, and short answers. Skim before any written paper or campus interview.

1. Theory Questions
  • What is Python and who created it? A high-level, interpreted, dynamically-typed language created by Guido van Rossum in 1991.
  • Why is Python called interpreted? Source is converted to bytecode and executed line-by-line by the CPython virtual machine — no separate compilation step.
  • List vs Tuple. List is mutable ([1,2,3]), tuple is immutable ((1,2,3)); tuples are faster and hashable.
  • What is PEP 8? The official Python style guide (indentation = 4 spaces, snake_case names, etc.).
  • What are mutable vs immutable types? Mutable: list, dict, set. Immutable: int, float, str, tuple, frozenset, bool.
2. Common Programs
  • WAP to check prime number (loop till √n).
  • WAP to reverse a string (s[::-1]).
  • WAP to find Fibonacci series using recursion + memoization.
  • WAP to count vowels in a string.
  • WAP to sort a list without sort() (bubble or selection).
3. Output / Predict-the-output
python
print(2 ** 3 ** 2)        # 512  (right-associative)
print([1,2,3] * 2)        # [1, 2, 3, 1, 2, 3]
print(bool([]), bool('0'))# False True
print('a' + str(1))       # 'a1'
4. Short Answers (1-2 marks each)
  • is vs ==is checks identity (same object), == checks value.
  • *args vs **kwargs — positional and keyword variable-length arguments.
  • Lambda — anonymous one-line function: lambda x: x*2.
  • List comprehension[x*x for x in range(5) if x%2==0].
  • Decorator — function that wraps another function (@staticmethod, @classmethod).
5. OOP Section
  • 4 OOP pillars in Python: Encapsulation, Inheritance, Polymorphism, Abstraction.
  • __init__ is the constructor.
  • self refers to the current instance.
  • Multiple inheritance is allowed (uses MRO — Method Resolution Order via C3 linearization).
6. Pro Tips for Top Marks
  • Always import modules at the top, not inside functions.
  • Use with open(...) for file handling (auto-closes).
  • Memorize time complexity of dict/set lookups (O(1)) — common viva question.
  • Quote PEP 8 in your essays — examiners love it.
AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

# program

Program

Python
# Quick demo for revision
for n in range(2, 11):
    if all(n % d for d in range(2, int(n**0.5) + 1)):
        print(n, end=' ')   # 2 3 5 7
Ready to move on?
// example library
Want more hands-on snippets in Python?
Browse 3 runnable examples · across 1 chapter · short, copy-paste-friendly · grouped by topic
Explore examples
// sharpen your skills
Put this into practice right now
LeetCode-style problems, graded difficulty, hints and expected outputs — learning beats passively reading every time.
Start Practicing
// feedback.matters()
Did this lesson help you?