Skip to content
CY-306 · Computer Workshop (Python Programming)/Important Questions

Computer Workshop (Python Programming) (CY-306) - Important Questions

  1. Unit 110 Marks High Priority

    Write a Python function to compute the factorial of a non-negative integer n. Implement both an iterative version and a recursive version. Show sample calls and outputs for n = 0, n = 5, and n = 7. Explain the difference in terms of call stack and time complexity.

    Core topic: Functions. Frequently asked in Unit 1 (general function design and recursion).

  2. Unit 17 Marks High Priority

    Explain different types of function arguments in Python with examples: positional arguments, keyword arguments, default arguments, and variable-length arguments using *args and **kwargs. Demonstrate a function that uses at least three of these argument types and show sample calls.

    Core topic: Function parameter types and calling conventions (commonly examined).

  3. Unit 17 Marks Medium Priority

    What is a lambda (anonymous) function in Python? Write examples using lambda with map(), filter(), and reduce() to (a) square a list of numbers, (b) filter even numbers from a list, and (c) compute the product of a list of numbers. Show input and output for each.

    Important modern-topic: anonymous functions and functional tools (often asked but less frequent than basic functions).

  4. Unit 17 Marks High Priority

    Explain scope and lifetime of variables in Python with examples. Distinguish between local, global, and nonlocal variables. Provide code that demonstrates modifying a global variable inside a function and using the nonlocal keyword inside a nested function.

    Core concept: variable scope and lifetime within functions (repeatedly tested).

  5. Unit 17 Marks High Priority

    Write a Python function to reverse a string. Show two implementations: one using slicing and one using an explicit loop. Demonstrate the function with the sample input "RGPV Python" and show the outputs.

    High-frequency practical task in Unit 1: string manipulation via functions (appears often in past papers).

  6. Unit 17 Marks High Priority

    Explain common escape sequences in Python strings (for example, \n, \t, \ and '). What is a raw string literal and when should it be used? Provide examples showing the difference between a normal string and a raw string when the string contains backslashes.

    Core Unit-1 topic: strings and escape sequences (highly frequent according to analytics).

  7. Unit 110 Marks High Priority

    Discuss Python string slicing and important string methods. Write examples demonstrating: indexing, slicing with positive and negative indices, step values, immutability of strings, and methods split(), join(), replace(), upper(), and format(). For the string "Data,Science,Python", show results of split(',') and then join() to rebuild a single string with spaces.

    Comprehensive question on string operations and slicing (frequently examined).

  8. Unit 114 Marks Medium Priority

    Given the following Python code, determine and explain the output:

    s = "Line1\nLine2\tEnd"

    def modify(text, prefix='->'): parts = text.split('\n') return prefix + ' ' + parts[1]

    print(s) print(modify(s))

    Explain each printed line and how escape sequences and the function call affect the result.

    Typical applied question: read and predict output of a Python code block combining functions and string escapes (appears occasionally).

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in