You are on page 1of 4

Question bank - Python

Ch. 1. Introduction to python

1. Why Python is famous? Discuss its features and the domains where it can be used for problem solving.
2. Discuss any two reasons why people use Python.
3. Python code execution is slower in comparison to C or C++. State True or False and justify.
4. Explain working on Python Virtual machine with suitable diagram.
5. What are Frozen Binaries?
6. What is Integrated Development Environment? Name any two Python IDEs.

Ch. 2. Data Types


1. How append() and extend() are different with reference to list in Python?
2. Differentiate between filter and map in Python using example.
3. Match the pair
Collection Type Description
a. List a. unordered and unindexed.
b. Tuple b. unordered, changeable and indexed
c. Set c. ordered and changeable
d. Dictionary d. ordered and unchangeable.

4. Explain List Comprehension with suitable example.


5. What is String formatting expression? Explain with two suitable examples. i.e. ‘...%s...’ % (values)
6. Explain List Data Structure. Name any four operations and give suitable example that changes list in place.
Ans: append, extend, remove, pop, del, sort, reverse
7. Compare List vs Dictionary.
8. Compare Tuple vs List.
9. Explain sequence unpacking wit suitable example.
10. Write a short note on
a. Set
b. Tuple
c. List
d. Dictionary
11. How sorted() can be used with list in Python? Give an example

ch3. Control flow, functions, Modules and packages

1. Explain in brief following statements with suitable example.


a. yield
b. import
c. pass
d. del
e. with/as

2. Discuss any 3 forms of Assignment statement.


a. Tuple assignment - spam, ham = 'yum', 'YUM'
b. List assignment - [spam, ham] = ['yum', 'YUM']
c. Sequence assignment - a, b, c, d = 'spam'
d. Extended sequence unpacking - a, *b = 'spam'
e. Multiple-target assignment - spam = ham = 'lunch'
f. Augmented assignment - spams += 42
3. What is an Extended sequence. Give example.
4. Discuss variable naming convention followed in Python.
5. Explain in brief following functions. Example expected.
a. map
b. join
c. range
d. filter
e. reduce

6. Write short note about pass, break and continue. Give example for each of them.
7. Write a program which showcase use of list comprehension with map and without map.
8. How map can be used in Python program? Explain with a suitable example.
9. Write a Python program to find reverse of given number using user defined function.
10. Find output
l=[(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
print l
11. Write list comprehensions for [3]
a. Write div(n) function which returns sum of positive divisors of given number
b. return a string with vowels removed
c. Finding intersection from two lists
d. x is an alphabet in word ‘MATHEMATICS’, x is a vowel
e. Take two list of same length as input and return a dictionary with one as keys and other as values

Functions and module packages


12. Explain with suitable example different parameter passing techniques in Python.
13. Describe concept of variable length of parameter with suitable example.
14. Explain how pass by reference is achieved in Python.
15. What are scope rules for variables in Python?
16. What is lambda function?
17. Explain Generators with suitable example.
18. Write a note on Modules and Packages. Explain with suitable example
19. Short note on
a. Factory functions
b. Function annotation
20. Python Functions are objects. Justify.

Ch4. Data Structures

1. Explain Set data structure. Discuss any three mathematical operations supported on set with suitable example.
2. What is dictionary in Python? Explain with an example.
3. Explain how stack and queues are implemented in Python.
4. Differentiate between tuples and sets based on their mutability, orderedness and uses.
5. How can all keys and values of a dictionary be traversed? Explain with an example.

Ch5. File operations

1. Give the syntax and significance of raw_input() and input() methods.


2. Explain any two file reading operations.
3. What is Object Serialization? Explain use of pickle module in serialization. Code snippet expected.
4. Explain concept logging. How it is implemented in Python. Code snippet expected.
5. What is ConfigParser.
6. File Program
a. Write a Python program to count the frequency of each word in a file and display the word and its
frequency as output.
b. Write a program which implements following
– SaveList() function to save list contents in a text file.
– LoadList() function which loads saved list content and prints length of the list on screen.
c. Write a Python program to read a random line from a file and print on screen.
d. Write a Python program to remove newline characters from a file.
e. Read a text file in Python and print no. of lines and no. of unique words.
7. Directory Program
8. Write a Python program to read a text file and do following:
a. Print no. of words
b. Print no. Statements

Ch 6. Object Oriented Programming [5 + 3 + 2]

1. Compare __str_ vs __repr__


2. Explain with suitable example how static variables can be implemented in class.
3. What are managed attributes i.e. Python descriptors? How are they implemented?
4. Explain in brief concept of docstring for functions. Explain docstring conventions with suitable example.
5. Write a note on Python Descriptors. Explain with suitable example.
6. Explain with suitable example how multipath inheritance is implemented in Python? Code snippet expected.
7. What is inheritance? Discuss any two types of inheritance implemented in Python. Code snippet expected.
8. Explain how object oriented concepts are implemented in Python?
9. What is C3 Linearization Algorithm?
10. With the help of an example, explain the significance of super() function.
11. Explain following operations
a. Issubclass()
b. Isinstance()
12. What is MRO? [2 Marks]
13. How operator overloading can be implemented in Python? Give an example.
14. Program
a. Write a script which implement a class Student having name and Roll number as data members,
constructor to initialize the object and a function which is similar to ToString() in java to return string
version of Students instance.
b. What are the differences between abstract class and interface? Write a python program in which
Maruti and Santro sub classes implement the abstract methods of the super class Car.

Ch. 7. Regular Expressions [3 +2]

1. Compare re.search() vs re.match() [2 Marks]


2. Explain following operations with suitable example
a. match()
b. findall()
c. Search()
d. Sub()
e. Finditer()
3. Explain any three optional flag values used in regular expression. [3 Marks]
4. Discuss any three methods implemented on regular expression object. [3 Marks]
5. Write a regular expression pattern for
a. Extracting emailed
b. Starts with digits followed by a space and then any characters.
6. Write a code snippet which uses regular expression to print first word of the string. [2 marks]
7. Write a code snippet which uses regular expression to print only those words from a string which start with a
vowel.
8. With the help of relevant example, explain any three metacharacters used in regular expressions.
9. Write a python program to retrieve strings starting with m and having 5 characters.

Ch8. Database Interaction SQL

1. Explain in brief the working of DB-API.


2. Write a note on Cursor.
3. Explain 6 steps of DB-API working with suitable example.
4. Write a function AddCustomer(CustID, CustName), which connects t CustDB and inserts a new record in
Customer Table.
5. What is the role of cursor while working with DB API? Describe the methods implemented on cursor.
6. Discuss methods implemented on Connection object.

Ch9. Image Processing using scikit Api


1. What is Google Vision API? Discuss its features. Give any two cases where it will be useful.
2. What is image processing? What features Scikit image processing offers? Give any two cases where it will be
useful.

Ch 10. Web Crawler using Python

1. Define
a. Web crawling
b. Web scraping
c. Spider
d. Scrapy
2. Write overview of working of Web scraping with suitable diagram.
3. Compare Scrapy Vs. BeautifulSoup.
7. Explain use of cssSelectors in web scraping with suitable example.
8. Write a program to read any webpage and print title of the web page.
9. Explain use of Xpath for Data Extraction in web scraping with suitable example.
10. Define web scraping. Discuss any two use cases where scraping is useful. Explain working of Scrapy with
suitable diagram.
11. Explain web scraping process with suitable diagram. Discuss the components used for extracting information.

You might also like