Python 15CS664 QuestionBank FINAL
Python 15CS664 QuestionBank FINAL
QUESTION BANK
Module 1
Module 2
Regular Expressions
29. What is the need of regular expressions in programming? Explain.
30. Discuss any 5 meta characters used in regular expressions with suitable example.
31. Discuss search() and findall() functions of re module.
32. What is the need of escape characters in regular expressions? Give suitable code snippet.
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
17. What is a Docstring? Why are they written?
18. What do you mean by “instance as returning value”? Explain with an example.
19. Justify the statement “Objects are mutable”.
20. What is an embedded object? Give an example.
21. When do we encounter AttributeError?
22. How do you find the memory address of an instance of a class?
Module 5
1. Write a note on HTTP.
2. Define socket. Explain relationship between user program and socket with a neat diagram.
3. Write a socket-based program to extract the data from a given webpage.
4. Write a socket-based program to retrieve image form the given webpage.
5. What is urllib? How is it different from socket?
6. Write a program to retrieve data from a webpage using urllib and to count the frequency of
words in that page.
7. Write a program to download an image from a given website using urllib.
8. How do you parse HTML using regular expressions? Write a program to illustrate the
same.
9. How do you parse HTML using BeautifulSoup? Write a program to illustrate the same.
10. Write a program to extract various parts of anchor tag using BeautifulSoup.
11. Briefly discuss XML and its tree representation with example.
12. Write a program to extract data from XML string.
13. How do you extract data from XML when XML document is containing multiple nodes?
Illustrate with a program.
14. Discuss the concept of JSON.
15. Write a program to parse data in JSON format.
16. What do you mean by API? Explain with suitable SOA diagram.
17. Write a program to extract location information using Google geocoding API.
18. Write a note on OAuth.
19. Discuss the concept of databases.
20. What are the important data types supported by SQLite?
21. How do you create a database table? Give a code snippet.
22. Explain the working of database cursor with suitable diagram.
23. Write a program to create a database StudentDB with attributes Name and Age. Insert n
records into the table and display the same.
24. What are different types of keys used in RDBMS? Explain.
25. Write a note on data modelling.
26. How do you join multiple tables? Illustrate with a program.
27. What is web scraping? Give an example.
28. Define a Port. What is the port number used in socket programming with HTTP?
29. What is a web service? Name the two formats that are used to exchange data in web.
30. Define a database.
31. What is a database management system? Give examples.
32. Explain the following database concept
a. Field b. record c. Primary Key d. table
33. What is SQL? Explain the following SQL statements
a. CREATE TABLE
b. INSERT
c. SELECT
d. DELETE
e. UPDATE