I cannot directly generate or send a downloadable PDF file.
However, I have organized all the filtered questions below
Python Programming (CST362) - Consolidated Question Bank
Based on University Examinations: June 2022, June 2023, May 2024, and April 2025.
Module 1: Basics, Selection, and Loops
Part A (3 Marks)
Variable Operations: Let x be "dog" and y be "cat". Write the values returned by: a) x4+""+4y b) x*len(x+y)
Loop Output: What will be the output of for j in range(2,10,4): print(j)?
Iteration Types: Differentiate between definite iteration and indefinite iteration in Python.
Number Logic: Write a program to reverse a number and find the sum of its digits.
Division/Types: What is the output of: (a) print (9//2) (b) print (9/2)?
Counters: Write a program to count even and odd numbers in a given set of n numbers.
SDLC: Jack says he will not bother with analysis and design but proceed directly to coding. Why is that not a good ide
Built-in Functions: Write the output of: i) round(12.57) ii) 5//2 iii) int(6.5).
Part B (14 Marks)
Logic: Find the eldest and youngest of three ages (without max/min functions) OR verify (a+b)^2 = a^2+2ab+b^2 with
Theory & Code: Enumerate selection structures and control statements with examples OR write a program for the fac
Software Process: Discuss the waterfall model steps with a diagram AND print a decreasing number pattern (5 4 3 2 1
Mathematical Logic: Print numbers between 100-1000 where the digit sum is divisible by 3 OR explain lazy evaluation
Patterns: Generate a number pattern (1, 12, 123...) AND explain loop types with examples.
Prime/Geometry: Print all prime numbers less than 1000 OR find the distance between (x1, y1) and (x2, y2).
Series: Program for the sum of the cosine series AND find X^Y without using standard functions.
Letter Pattern: Generate a letter pattern (A, AB, ABC...) OR generate prime numbers within a given range.
Module 2: Lists, Strings, Files, and Recursion
Part A (3 Marks)
List Comprehension: Create a list of squares for numbers 0 to 9 using list comprehension.
Functions: Write a user-defined function to generate even numbers between 1 and 25.
Recursion: Define recursion and write a program for the Fibonacci series.
Higher-Order: Define mapping, filtering, and reducing with examples.
Indexing: Illustrate the use of negative indexing in a list with an example.
File I/O: Write code to write text to [Link], then read and print it.
Slicing: Write the output for S = "Computer": S[::2], S[::-1], and S[:].
Recursive GCD: Write a recursive function to find the GCD of two numbers.
Part B (14 Marks)
Recursion/Files: Describe recursive functions with an example AND explain reading numeric values from a file to perf
Data Structures: Compare lists, tuples, and sets OR write a dictionary program to store and display ages by name.
Cryptography: Define Caesar cipher and write programs for distance +3 encryption/decryption.
Dictionary Logic: Explain dictionary syntax (adding, accessing, traversing) OR demonstrate four list methods with exa
Conversion: Program to convert a decimal number to binary.
String Counting: Count each character's appearance in a string using a dictionary.
List Processing: Create a min_max() function for a list OR read n integers and separate positive/negative numbers int
String Manipulation: Perform tasks (split, upper, find, replace) on "Python rules!".
Median: Find the median of numbers in a file without using standard functions.
Module 3: Turtle Graphics and Image Processing
Part A (3 Marks)
Turtle Speed: How can you set drawing speed in the Turtle module?
Tkinter Basics: List the steps to create a GUI application using Tkinter.
Turtle Drawing: Write a program to draw a star using turtle.
Event-Driven: Explain event-driven programming with an example.
Libraries: List any three image processing Python libraries.
Movement: Illustrate the function of setheading(0), forward(50), and left(90).
UI Theory: Describe two differences between terminal-based interfaces and GUIs.
Part B (14 Marks)
Graphics: Draw a square and hexagon using turtle AND describe modules for converting color images to grayscale.
GUI Design: Program to calculate rectangle area OR display an image with a caption in a GUI.
Mouse Interaction: GUI program that draws coordinates of mouse presses on a canvas.
Image Filtering: Write a program to blur an image OR write a program for edge detection.
Turtle Delays: Draw a blue pentagon without a loop and with a 2-second delay.
Turtle Shapes: Draw a star shape using turtle AND explain basic image processing functions.
Age Calculator: GUI program to take birth date and output age.
Image Scaling: Write a function to shrink an image by a given factor.
Module 4: Object Oriented Programming (OOP)
Part A (3 Marks)
Overriding: How can you achieve method overriding in Python?
Constructors: How does init differ from other methods?
Class Terms: Explain accessors and mutators in class definitions.
Destructors: How do you create a destructor? Give an example.
Class Logic: Write a class with get_distance (km) and print_distance (meters) methods.
String Representation: Explain the str method and its utility.
Inheritance Types: Compare multiple and multilevel inheritance.
Part B (14 Marks)
Class Implementation: Create a Car class, access/modify its attributes AND demonstrate polymorphism with Rectang
Abstract Classes: What is an abstract class? Explain with an example.
Exceptions: Illustrate exception handling with examples.
Inheritance: Explain single and hybrid inheritance with code examples.
Calculator: Write a program for a simple calculator using a class.
Overloading: Demonstrate polymorphism using function overloading OR implement an Abstract Base Class for Shape
Operators: Overload + and * for a Complex number class.
Rational Numbers: Implement a Rational class with operator overloading.
Module 5: NumPy, Pandas, and Matplotlib
Part A (3 Marks)
Matrix Creation: Create a 3 × 3 matrix A with random integers (1–10).
Missing Data: How does isnull() contribute to handling missing values?
System Module: Demonstrate the significance of the sys module.
Web Framework: Narrate the use of Flask in web development.
Randomness: How do you assign a random number to a variable?
OS Module: What is the use of the os module in Python?
NumPy Logic: Output of arr1+arr2[0].reshape((1,2)) for 3 × 2 arrays.
Pandas Indexing: Difference between loc and iloc in DataFrames.
Part B (14 Marks)
NumPy Operations: Element-wise addition, mean/SD, scalar multiplication, and dot product.
Visualization: Create a Matplotlib plot for sin(x) and cos(x) with legends and labels.
Data Analysis: Pandas commands to sort names, find highest grades, and filter by gender.
CSV Writing: Program to write a specific table (Name, Age, City...) to a CSV file.
Matrix Math: Explain matrix multiplication using NumPy arrays.
File Systems: Print names of all items in the current working directory.
Branch Stats: Use Pandas to find average CGPA per branch and filter top students.