Python - 04-10-22
Python - 04-10-22
Python - 04-10-22
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
B.Tech. Summer 2022 - 23 Examination
Semester: 8 Date: 04/10/2022
Subject Code: 203105467 Time: 2:00pm to 4:30pm
Subject Name: Python Programming Total Marks: 60
Instructions:
1. All questions are compulsory.
2. Figures to the right indicate full marks.
3. Make suitable assumptions wherever necessary.
4. Start new question on new page.
tuple = {}
tuple[(1,2,4)] = 8
tuple[(4,2,1)] = 10
tuple[(1,2)] = 12
_sum = 0
for k in tuple:
_sum += tuple[k]
print(len(tuple) + _sum)
a) 34 b) 12
c) 31 d) 33
Page 1 of 2
11. What is a python library that can be used to send and receive data over HTTP?
12. Which of the following options can be used to read the first line of a text file data.txt?
a) f = open(‘data.txt’); f.read()
b) f = open(‘data.txt’,’r’); f.read(n)
c) myfile = open(‘data.txt’); f.readline()
d) f = open(‘data.txt’); f.readlines()
13. ______ represents an entity in the real world with its identity and behavior.
14. ______ command helps us to reset the pen (turtle).
15. What is delattr(obj,name) used for?
Q.2 Answer the following questions. (Attempt any three) (15)
A) What are the key features of Python?
B) What are python modules? Name some commonly used built-in modules in Python? Explain use
of anyone of the modules using example.
C) Explain the following python regular expression function with an example: findall(), split() and
search().
D) Write a python program to implement Fibonacci series of n elements.
Q.3 A) Is String a mutable data type? Also explain the string operations length, indexing and slicing in (07)
detail with an appropriate example.
B) Write a python program that sorts the list [34, 25, 81, 12, 5] using merge sort. (08)
OR
B) Create a Python program to read a text file and do following: (08)
1. Print no. of lines
2. Print no. of unique words
3. Count the frequency of words in a file
4. Find the longest words
Q.4 A) Which are the OOP concepts of class? Explain any one of them using a Python Example. (07)
OR
A) Write a python program to get an output like the below image. (07)
B) Write a python program to implement linear search and binary search. (08)
Page 2 of 2