Python Application Programming (15CS664) : Question Bank For The Subject
Python Application Programming (15CS664) : Question Bank For The Subject
Module 4:
1. Define class and object. Given an example for creating a class and an object of that class.
2. What are attributes? Explain with an example and respective object diagram.
3. Write a program to create a class called Point with two attributes x and y. Write
following functions and demonstrate the working of these functions by creating suitable
objects.
a. To read attribute values
b. To display point as an ordered pair
c. To find distance between two points
4. Write a program to create a class called Rectangle with the help of a corner point, width
and height. Write following functions and demonstrate their working:
a. To find and display center of rectangle
b. To display point as an ordered pair
c. To resize the rectangle
5. Differentiate copy.copy() and copy.deepcopy() with suitable examples.
6. Discuss the methods isinstance(), hasattr() and vars() with suitable examples.
7. Differentiate pure functions and modifiers with suitable examples
8. Explain assert statement. Illustrate the situation of getting AssertionError exception.
9. List out the object oriented characteristics possessed by Python.
10. Differentiate methods and functions.
11. Discuss the significance of __init__() method in Python with a proper example code
snippet.
12. Briefly discuss self keyword in Python.
13. What does __str__() method do in Python? Illustrate with a code snippet.
14. Discuss operator overloading. Mention any five operators with respective special
functions to be overloaded in Python.
15. Write a program to add two point objects by overloading + operator. Overload __str__()
to display point as an ordered pair.
16. Write a program to create a class Time to represent time in HH:MM:SS format. Perform
following operations:
a. Overload + to add two time objects
b. Overload + to add a numeric value to a time object (commutative)
c. Overload __str__() to display time in appropriate format
1. Write a program which repeatedly reads numbers until the user enters “done”. Once
“done” is entered, print out the total, count, and average of the numbers. If the user enters
anything other than a number, detect their mistake using try and except and print an error
message and skip to the next number.
2. Mention the regular expression for the following pattern
a. Starts with a number followed by minimum of six characters
b. Having only alphabets and ending with rns
c. Having four spaces , followed by special characters
d. Beginning with (( and having multiple characters
3. List the salient features of Dictionaries over Lists. Explain how in operator work with
dictionaries with an example.
Assignment 3: