PML QB
PML QB
Module 1
Theory
1. What are the different ways to run a python program?
2. What is the meaning of Software development process and give a case study ?
3. What are the different data types used in Python?
4. What are the rules for declaring Variables in python?
5. What are keywords? Give examples
6. What is the important of Comments ?
7. How to input values in Python?
8. What is type conversion and what are its variations? (Coercion and Casting)
9. How is Numerical data dealt with in Python? How about Characters then?
10. What are escape characters?
11. What are the different Operators using in Python?
12. How can you display content in Python? What are the different formats
13. What are modules? Give more details about math module
14. How does python work?
15. Program: Detect syntax errors
16. Find the area of a circle given center point and one point on the perimeter
17. Write a Python script to find nCr .Use math module to find the factorial
Module 2
1. Explain how if conditions are used?
2. What do you mean by Python Scope?
3. Give the different loops in Python with examples
4. What is lazy evaluation? Give example
5. What is function? Give syntax.
6. What do you mean by parameter passing? What are the different types of arguments?
7. What is recursive function?
8. What are Strings? Give the different functions used by it?
Programs[Module 1 and 2]
1. Prime numbers upto a limit
2. Armstrong numbers upto a limit
3. Recursive function that takes a number and returns the sum of all the numbers
from zero to that number.
4. Recursive function that takes a number as an input and returns the factorial of that
number.
5. Recursive function that takes a number ‘n’ and returns the nth Fibonacci number.
6. Recursive function that takes an array of numbers as input and returns the product
of all the numbers in the array.
7. Reverse the contents of an 1D array without using a second array.
8. Write a program to validate the credentials. Assume that the usernames are stored
in an array of strings called USERNAME and the corresponding passwords are
stored in another array of strings called PASSWORD such that password[i] is the
password for the user username[i].
9. You are given a list and your task is to divide it to make two smaller lists. The
sublists should be made from alternate elements in the original list. So if the
original list is {5,1,4,12,6}, then one sublist should be {5,4,6} and the other
should be {1,12}. 12.
10. A program that takes three points in a 2D plane and determines whether they are
collinear. Two pairs of points are collinear if they have the same slope.
11. Simple desktop calculator using Python.
12. Create, concatenate, and print a string and access a sub-string from a given string.
13. Write a program to create, append, and remove lists in Python using NumPy.
14. Program to find the largest of three numbers.
15. Convert temperature values back and forth between Celsius (c), and Fahrenheit
(f). [Formula: c/5 = f-32/9]
16. Recursive function to add two positive numbers.
17. Recursive function to multiply two positive numbers.
18. Recursive function to find the greatest common divisor of two positive numbers.
19. A program that accepts the lengths of three sides of a triangle as inputs. The
program should output whether or not the triangle is a right triangle (Recall from
the Pythagorean Theorem that in a right triangle, the square of one side equals the
sum of the squares of the other two sides
20. Write a function and define a module to find Fibonacci Numbers and import the
module to another program.
21. Program to check whether the given number is a valid mobile number or not using
functions. Rules:
a. Every number should contain exactly 10 digits.
b. The first digit should be 7 or 8 or 9 16.
22. Input two lists from the user. Merge these lists into a third list such that in the
merged list, all even numbers occur first followed by odd numbers. Both the even
numbers and odd numbers should be in sorted order.
23. Explain the use of return statement in function. Write a Python program using
function to find the sum of first ‘n’ even numbers and return the result to main
program. [Previous Year]
24. Write Python Program to reverse a number and also find the sum of digits of the
number (prompt the user for input). [Previous Year]
25. Write Python program to count the total number of vowels, consonants and blanks
in a string. . [Previous Year]
26. What are default arguments and named arguments in function? Write a menu
driven Python program to input a number and implement the following operations.
Use separate functions to implement each operation.
i)check whether the number is odd or even
ii) check whether the number is positive, negative or zero [Previous Year]
Module 3
1. What is List? What are the different operations in list? Give examples
2. What do you mean by List Comprehension
3. What is Tuple? What are the different operations in tuple? Give examples
4. What is Dictionary? What are the different operations in dictionary? Give examples
5. What is Set? What are the different operations in set? Give examples
6. What do you mean by reverse lookup?
7. Case Study – Data structure selection
8. Display today’s date along with tomorrow’s and yesterday’s date in different formats
Programs[Module 3]
1. Convert a List to a Tuple and vice versa.
2. Convert a Tuple to a List and vice versa.
3. Convert a List to a Set and vice versa.
4. Convert Dictionary Keys to a List and Dictionary Values to another List .
5. Convert a List of Tuples to a Dictionary and vice versa.
6. Check Common Elements Between Two Sets.
7. Merge Two Dictionaries.
8. Add an Element to a Set.
9. Remove an Element from a Dictionary.
10. Sort a List and Convert it to a Tuple.
11. Find the Difference Between Two Sets.
12. Count Frequency of Elements in a List Using a Dictionary.
13. Flatten a Nested List.
14. Find the Symmetric Difference Between Two Sets.
15. Reverse Keys and Values in a Dictionary.
16. Group Elements of a List Based on a Condition.
17. Count Common Elements in a List Using a Set.
18. Check if a Tuple Contains All Unique Elements.
19. Create a Dictionary from Two Lists.
20. Sort a Dictionary by Values.
21. Find the Cartesian Product of Two Sets.
22. Find the Intersection of Multiple Sets.
23. Remove Duplicate Tuples from a List.
24. Merge Two Dictionaries and Add Values for Common Keys.
25. Find the Frequency of Characters in a String Using a Dictionary.
26. Generate All Subsets of a Set.
27. Find the Second Most Frequent Element in a List.
28. Write a Python program to read list of positive integers into a list and separate the
prime and composite numbers into two different list. [Previous Year Qn]
29. Write a program to remove all duplicate elements from a list.( do not keep any copy of
the repeating element) Hint: use set for efficient implementation [Previous Year Qn]
Module 4
1. What is Objects and classes? Give examples wrt programs and real life
2. What is constructors? What are the different types?
3. What is the difference between Accessors and mutators?
4. What are the oops concepts?
5. What do you mean by instance variables?
6. What is inheritance? What are the different types?
7. What is Abstract Class? Give example wrt programs
8. What is polymorphism?
9. Differentiate between function overloading and operator overloading?
10. Differentiate between function overloading and function overriding?
11. What are Exceptions in Pythons? How to handle them? Give examples [Seven
examples].
Programs
1. Create a class BankAccount with methods for deposit, withdrawal, and checking
balance. Use constructors to initialize account details.
2. Implement a program to demonstrate method overriding by creating a base class
Shape and derived classes Rectangle and Circle that override the area() method.
3. Write a program to demonstrate operator overloading by implementing a class
Complex that overloads the + operator to add two complex numbers.
4. Develop a program to demonstrate abstract classes by defining a class Vehicle with an
abstract method fuel_efficiency() and implementing it in derived classes like Car and
Bike.
5. Write a program to handle custom exceptions like NegativeNumberException when a
user enters a negative number in a mathematical operation.
6. Create a program to demonstrate multiple inheritance by implementing classes
ElectricCar and GasolineCar that are inherited by HybridCar.
7. Implement a program to demonstrate runtime polymorphism using method overriding
in a base class Person and derived classes Student and Employee.
8. Design a program to demonstrate encapsulation by creating a class Account with
private attributes and public getter and setter methods.
9. Create a program to demonstrate the use of super() for calling parent class methods
and constructors in a derived class.
10. Implement a program to demonstrate the use of static methods in a class
MathOperations for common utility tasks like addition, subtraction, and finding the
square root.
11. Write a program to demonstrate hybrid inheritance by implementing a class hierarchy
involving Animal, Bird, and FlyingBird.
12. Create a class Library that manages books, and use inheritance to extend it into
DigitalLibrary with additional features like managing e-books.
13. Write a program to demonstrate the concept of class methods by implementing a
factory method in a class Student to create objects from a dictionary.
14. Create a class Employee and use multiple constructors to initialize employee details in
different ways.
15. Implement a program to create a base class Game with a method play() and derived
classes Football and Chess that override the method for specific behaviors.
16. Write a program to create a class Transaction that tracks and logs transactions using a
list. Include features to undo and redo transactions.
17. Develop a program to demonstrate file handling in a class FileManager that reads,
writes, and appends data to a file while handling exceptions.
18. Implement a program that demonstrates the use of __call__ in a class to make objects
callable like functions.
Module 5
Theory: Study everything in syllabus for Module 5 – all are very important
Programs
1. Write Python code to plot histogram of marks of students stored in a list L, with
proper title, xlabel and ylabel using matplotlib library.
2. Write a python program to read numbers from a file named num.txt. Write all positive
numbers from num.txt to a file named positive.txt and all negative numbers to a file
negative.txt.
3. Write a Python program using the os module to list all files in a given directory and
display their sizes in bytes.
4. Use the sys module to write a Python script that accepts command-line arguments to
add two numbers and display the result.
5. Write a Python program to check if a file exists using the os module and, if it exists,
print its absolute path.
6. Write a Python program to read a file data.txt and count the occurrences of each word,
storing the results in a new file word_count.txt.
7. Create a Python program to merge the contents of two text files file1.txt and file2.txt
into a third file merged.txt.
8. Write a Python program to read a text file, replace all occurrences of the word
"Python" with "Programming," and save the changes to a new file.
9. Write a Python program to read a binary file containing student records and display
them in a readable format.
10. Create a program to write a list of numbers to a binary file and then read them back to
calculate their sum.
11. Develop a Python program to copy the contents of one binary file to another binary
file.
12. Write a Python program to create a NumPy array and demonstrate arithmetic
operations like addition, subtraction, and multiplication.
13. Write a Python script to illustrate indexing and slicing of a 2D NumPy array with
examples.
14. Create a NumPy array and sort it in ascending and descending order. Display the
sorted arrays.
15. Write a Python program to perform matrix addition, subtraction, and multiplication
using NumPy arrays.
16. Generate a 4x4 matrix with random integers between 1 and 100 using NumPy and
find its transpose.
17. Create a Python program to solve a system of linear equations using NumPy arrays.
18. Write Python code to plot a line graph of temperature data for a week, with proper
title, x-label, and y-label.
19. Create a program to plot a bar chart for sales data stored in a dictionary.
20. Write a Python script to plot a scatter plot of height vs. weight of students stored in
two lists.
21. Write a program to plot multiple lines on a graph with custom x-ticks, y-ticks, and
legends for each line.
22. Create a Python program to plot a sine wave and customize the x-label, y-label, and
title.
23. Write a Python script to demonstrate the use of gridlines and legends on a plot.
24. Write a Python program to read a CSV file products.csv and display the contents row
by row.
25. Create a program to read a CSV file and find the row with the maximum value in a
specific column.
26. Write a Python program to filter rows from a CSV file employees.csv where the
salary is greater than 50,000 and save the result to filtered.csv.
27. Write a Python program to read a CSV file data.csv into a Pandas DataFrame and
display the first 5 rows.
28. Create a Pandas program to filter rows in a DataFrame where a column value is
greater than a given threshold.
29. Write a Python program to remove duplicate rows from a DataFrame and display the
unique rows.
30. Write a Python program to calculate the mean, median, and standard deviation of a
column in a Pandas DataFrame.
31. Create a Pandas program to group data in a DataFrame by a specific column and
calculate the sum for each group.
32. Write a Python program to visualize the sales data of a company stored in a Pandas
DataFrame using a bar chart.
33. Write a program to add a new column to a DataFrame, calculate its values based on
existing columns, and save the updated DataFrame to a new CSV file.
[Study the Previous Years Questions also – not all are included]