Professional Documents
Culture Documents
1. Write the syntax for creating a class and objects. Demonstrate the same with a
sample program
2. What are __init__ methods in python? Demonstrate with an example program.
3. What is inheritance explain with an example? What are the different types of
inheritance supported in python?
4. Explain the advantages of inheritance. Demonstrate Single inheritance with an
example.
5. Demonstrate multiple and multilevel inheritance with examples for each
6. Demonstrate the concept of polymorphism with an example
7. Explain abstraction and encapsulation with an example
8. Explain polymorphism with an example
9. Explain how operators are overloaded using magic methods. List the magic
methods used to overload the operators.
10. Differentiate between method overloading and method overriding with
example
11. Explain method overriding and super key words with suitable example.
Sample Programming questions:
12. Create a class called Book with data attributes title, author
and publication and include following methods: __init___ function to initialize all the details
of the book, printdetails() to print all the details of the book
13. Develop a program to check whether three points are collinear or not. Create a
class having x and y coordinates as attributes and a method taking point
objects as parameters and prints appropriate message.
14. Create a class named quadratic, where a, b, c are data attributes and the
methods are: __init__() to initialize the data attributes and roots() to compute
the quadratic equation
15. Create a class called Circle having radius as attribute, and __init__
constructor, area(), perimeter() as methods to find the area and perimeter of a
Circle object.
16. Develop a program with a base class Person having name and age as
attributes, a init constructor and display method to display the attributes.
Derive another class Student with attributes USN and percentage as attributes,
init and display methods. Create an object of student class and initialize and
display all attributes
17. Create two base classes named clock having hh,mm ,ss as attributes and
calendar having dd,mm,yy as attributes. Based on these two classes derive a
class calendarclock, which inherits from both the classes which displays
month details, date and time using the methods of the base classes. Create an
object and invoke appropriate methods.
18. Develop a class called complex having r and im as real and imaginary values.
Overload +, - , * operators to perform addition, subtraction and multiplication
of two complex numbers.
19. Create a class called Bank having name, adds, acno, and balance as attributes.
Include following methods: init constructor, withdrawl(), deposit(),
balenquiry(). Create an object and execute the methods based on user’s choice.
20. Write a program to create class Distance, having feet and inches as attributes.
Overload + operator to add two Distance objects, and > operator to compare
two distance objects.
1. What are Lists? Explain with examples the different ways to create a list. 4 marks
2. Why lists are called Mutable. Discuss the following List operations and functions
with examples:
i. Accessing, Traversing and Slicing the List Elements 5 marks
ii. + (concatenation) and * (Repetition) 2 marks
iii. Append, extend, sort, remove and delete 6marks
iv. len , sum, min and max 4 marks
v. split and join 2marks
3. What is list in Python? Demonstrate use of any three methods of list. 6 marks
4. Differentiate between the following:
1. pop() and remove() methods of list. 2marks
2. Del statement and pop() method of list. 2marks
3. append() and insert() methods of list. 2marks
5. Demonstrate the use of range function with examples 3marks
6. Demonstrate with example to access all the elements of a list using index and using
item of the list 4 marks
7. With example illustrate how the list can be passed as arguments to a function?
5 marks
8. Write a short note on Dictionary in python. 5 marks
9. Demonstrate the following with an example for each
i)Creation of dictionary
ii) Accessing elements of the dictionary
iii) Modifying key:value pairs 6 marks
10. Explain len(), all(), any() sorted() built in functions on dictionary 4 marks
11. Demonstrate pop(),popitem(), fromkeys(), get(), setdefault() and update() methods
with example for each. 6 marks
12. Demonstrate the following methods on dictionary with examples.
i)values() ii)keys() iii)items() 6 marks
13. Write a short note on tuples and sets 6 marks
14. Differentiate between lists and tuples 5marks
15. Explain any 5 methods on sets with an example for each 5marks
16. Compare list, tuple, sets and Dictionaries 8 marks
Programming questions:
18. Write a Python program to sum all the items in a list without using sum(). 4 marks
19. Write a Python program to get the largest and smallest number from a list without
using methods. 5 marks
20. Develop a Python Program to separate the given list elements into a list of odd and
even numbers. 5 marks
21. Write a program to implement binary search algorithm on a list. 6marks
22. Write a Python program to count the number of strings where the string length is 2 or
more and the first and last character are same from a given list of strings. Sample List:
['abc', 'xyz', 'aba', '1221'] Expected Result: 2 ---- 6 marks
23. Write a Python program to get the frequency (occurrence count) of the elements in a
list. -5 marks
24. Write a Python program to print the following from the 10 integer inputs entered by
the user stored in a list : -----8 marks
i. Total number of positive numbers
ii. Total number of negative numbers
iii. Total number of odd numbers
iv. Total number of even numbers
v. Total number of 0s.
25. Construct a dictionary that contains usernames as the keys and passwords as the
associated values. Make up the data for five dictionary entries. ----6marks
26. Write a Program to Dynamically Build a List from user inputs and demonstrate list
slicing with example.---6 marks
27. Write a Python Program That Accepts a Sentence as Input and Removes All
Duplicate Words. Print the Sorted Words. -6marks
28. Write a program to check whether an item exists within a tuple. If the item is present
print the index of the item else print a message “sorry not found”- 6 marks
29. Write a python program to separate alphabets,digits into two separate lists.
Example: s=”hello123” L1=[‘h’,’e’,’l’,’l’,’o’] L2=[1,2,3]. -6 marks
30. Write a python program that takes a range of input and creates a dictionary where in
key includes the number in the range and 2nd element as the square of that number.
example: input 4 and 6 o/p: dict=[4:16, 5:25, 6:36]—8 marks
9. Write Python Program to Find the Longest Word in a File. Get the File Name from User.
10. Write Python program to read and display rows in "employees.csv" CSV file
that start with employee name "Jerry".
11. Write Python program to write the data given below to a CSV file.
Name,USN, percentage
ABC,1DS18XX001, 67
XYZ,1DS18XX002,75
PQR,1DS18XX003,82
Regular Expressions:
1. Define regular expression and list out all the advantages of the regular expression.
2. Describe any ten metacharacters with examples.
3. Write a regular expression which matches strings which starts with a sequence of
digits—at least one digit—followed by a blank and after these arbitrary characters.
4. Briefly explain the importance of the raw string notation.
5. Write a Python program to remove all leading zeros' from an IP address
6. Write a Python program to extract year, month and date from an url.