Amit Sir – Python Tutor

Top 10 Output Questions on Lists, Functions & Dictionaries – CBSE Class 12 Python

By Amit Sir | October 6, 2025

👁️ 0 views

Why Practice These Questions?

Output-based questions on Lists, Functions, and Dictionaries are crucial for scoring high in CBSE Class 12 Computer Science exams. These 10 Python programs are carefully chosen for board-level preparation.

Top 10 Python Output Questions

  1. List Copy vs Reference
    def mix(L):
        L2 = L
        L3 = L[:]
        L2.append(100)
        L3.append(200)
        print("L2:", L2)
        print("L3:", L3)
        print("L :", L)
    
    nums = [10, 20, 30]
    mix(nums)
    print(nums)
    Output:
    L2: [10, 20, 30, 100]
    L3: [10, 20, 30, 200]
    L : [10, 20, 30, 100]
    [10, 20, 30, 100]
    Tip: Assigning L2 = L references the same list, while L3 = L[:] creates a copy.
  2. List Mutation in Function
    def tricky(L):
        for i in range(len(L)):
            L[i] = L[i] + sum(L[:i])
        return L
    
    nums = [2, 4, 6, 8]
    print(tricky(nums))
    Output: [2, 6, 14, 30]
  3. Dictionary Key Check
    def fun(d):
        for k in list(d.keys()):
            if k.lower() in 'aeiou':
                d[k] += 1
            else:
                d.pop(k)
        return d
    
    data = {'A': 10, 'B': 20, 'E': 30, 'C': 40}
    print(fun(data))
    Output: {'A': 11, 'E': 31}
  4. List Rotation Mystery
    def mystery(L):
        x = []
        for i in range(len(L)):
            x.append(L[i:] + L[:i])
        return x[-1][1]
    
    lst = [1, 2, 3, 4]
    print(mystery(lst))
    Output: 1
  5. Combine Two Lists into Dictionary
    def combine(L1, L2):
        D = {}
        for i in range(min(len(L1), len(L2))):
            D[L1[i]] = L2[-(i+1)]
        return D
    
    print(combine(['x','y','z'], [1,2,3]))
    Output: {'x': 3, 'y': 2, 'z': 1}
  6. Function Scope vs Mutation
    def modify(L):
        L = L + [50]
        L.append(60)
        print(L)
    
    L = [10, 20, 30]
    modify(L)
    print(L)
    Output:
    [10, 20, 30, 50, 60]
    [10, 20, 30]
  7. Dictionary Update
    def swap_values(D):
        for k in D:
            D[k] = D[k] * 2
        return len(D)
    
    data = {'a':5, 'b':10, 'c':15}
    print(swap_values(data))
    print(data)
    Output:
    3
    {'a': 10, 'b': 20, 'c': 30}
  8. Running Sum of List
    def calc(L):
        for i in range(1, len(L)):
            L[i] += L[i-1]
        return L[-1]
    
    nums = [1,2,3,4]
    print(calc(nums))
    Output: 10
  9. Update Dictionary with Key Check
    def update_dict(D, key, value):
        if key in D:
            D[key] += value
        else:
            D[key] = value
        return D
    
    data = {'A': 10, 'B': 20}
    print(update_dict(data, 'B', 5))
    print(update_dict(data, 'C', 7))
    Output:
    {'A': 10, 'B': 25}
    {'A': 10, 'B': 25, 'C': 7}
  10. Reverse List and Sum
    def rev(L):
        return L[::-1]
    
    def add(L):
        return sum(L)
    
    print(add(rev([1,2,3,4])))
    Output: 10

Need Help Mastering Python?

Join Amit Sir’s CBSE Class 12 Computer Science coaching to score 90+ in boards.

📱 Call Now 💬 WhatsApp