Professional Documents
Culture Documents
462 Question Paper-1
462 Question Paper-1
462 Question Paper-1
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
B.Tech. Winter 2017 – 18 Examination
Semester: 4 Date-13-01-2018
Subject Code: 03105255 Time: 10.30am to 01.00pm
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.
Page 1 of 2
11. What is the output of the code shown below?
import re
a = re.compile('[0-9]+')
print a.findall('3 trees')
a) [] b) [‘3’] c) Error d) [‘trees’]
12. Give the output of following Python code:
import re
print re.sub('morning', 'evening', 'good morning')
13. Give the output of following Python code:
x=2
for i in range(x):
x += 1
print (x)
14. Which of the following functions will return the symmetric difference between two sets, x and y?
a) x | y b) x ^ y c) x & y d) x – y
15. Demonstrate any two methods of dictionary.
Q.2 Answer the following questions. (Attempt any three) (15)
A) Write a Python program to print Fibonacci series upto n terms.
B) What is exception? Explain need of exception handling.
C) Write a Python programto create a Function to swap values of a pair of integers.
D) Briefly describe the methods of RE module.
Q.3 A) Write a Python program to implement the concept of inheritance. (07)
B) Write a program to calculate arithmetic operations. For this purpose you have to create one (08)
module “Arithmetic”, which includes all arithmetic operation. Import “Arithmetic” module in your
program for all operations.
OR
B) Explain the control structures(if,if-else,elif,for,while) used in python. (08)
Q.4 A) Write a program to count the occurrences of each word in the following sentence using dict(). (07)
the clown ran after the car and the car ran into the tent and the tent fell down on the clown and the
car
OR
A) Write a program in Python that reads a file and adds backslash (\) before every double quote it (07)
encounters. And then writes it to another file in the same folder.
For example:
If the file name is TestFile1.txt with text Jack said, “Hello Pune”. The output to the file TestFile2.txt
should be Jack said,\“Hello Pune\”.
B) List out features of Python Programming. What are the differences between C and Python? (08)
Page 2 of 2