Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Python MQP2

Uploaded by

akhilpb09
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Python MQP2

Uploaded by

akhilpb09
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ST JOSEPH ENGINEERING COLLEGE, MANGALURU

An Autonomous Institution
Fourth Semester B.E. Degree (Autonomous) Examinations
USN: 21CSE6044

Duration: 3 Hrs Maximum Marks: 100

Introduction to Python
Note:
1. Part-A is mandatory.
2. Answer any five full questions from Part-B choosing at least one from each module.
3. Missing data may be suitably assumed.
PART-A
C Mark
Q.No. Question BL PO
O s
1 Which of the following character is used to give single-line comments L2 1 1 2
in Python?
a) # b) @
c) “”” d) //
“””
2 Which of the following is used to define a block of code in Python L2 1 1 2
language?
a) Indentation b) Brackets
c) Keyword d) None
3 What will be the output of the following Python code? L2 2 2 2
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a == b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)
a) 3 is maximum b) 3 is equal to 4
c) 3 is equal to 3 d) 4 is maximum
4 What is the purpose of the return statement in a function? L2 2 1 2
a) To stop the execution of the b) To print a value to the
function console
c) To return a value to the d) To define a recursive
caller function

1|4
Q.No. Question BL CO PO Marks
5 What is the full form of CSV file L2 5 1 2
a) Colon separated value b) Capital separated value
c) Context separated values d) Comma separated value
6 What is the output of the following code: L3 2 2 2
def myfunc(a):
a=a+2
a=a*2
return a

print myfunc(2)
a) 8 b) 16
c) Indentation Error d) Error
7 What is the output of the following code: L3 2 2 2
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a) 0 0 010 2 b) 012
c) 12 d) Error

8 What is the output of the following code: L2 3 2 2


d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
a) True b) False
c) Arithmetic Error d) {"john":40,"peter":45}>{"jo
hn":466,"peter":45}
9 Which module in Python supports regular expressions? L2 4 1 2
a) regex b) pyre
c) re d) pyregex
10 What is the output of the following code: L2 2 2 2
list=[5,10,15,20,25]
print(list[::-3])
a) 20 5 b) 25 15 5
c) 25 10 d)
20 10

2|4
Q.No. Question BL CO PO Marks
PART-B
Module-1
1 a) Write the python program L3 1 3 8
(i)To find the given number is positive or negative
(ii)To display the number from 1 to 10 using for loop

b) Define variable in python and list the rules of python variables? L2 1 6 8


OR
2 a) Write the Output for the following (2*5) L3 1 4 8
x=10
y=20
print (x+y)

x='100'
y='5'
print(x+y)

a='Hello'
b=4
print(a+b)

x=50
x>0 and x<10

n=10
print(n%2==0 or n%3==0)
b) Describe Arithmetic Operators, Assignment Operators, L2 1 1 8
Comparison Operators, Logical Operators and Bitwise Operators
in detail with examples.
Module-2
3 a) Write a python program to demonstrate the concept of function L3 2 4 8
using with parameter and return type and discuss in brief
b) How Python handles Exception? Explain with appropriate L3 2 1 8
programming examples.
OR
4 a) For a given list num=[45,22,14,65,97,72], write a python program L3 2 6 8
to replace all the integers divisible by 3 with “ppp” and all integers
divisible by 5 with “qqq” and replace all the integers divisible by
both 3 and 5 with “pppqqq” and display the output
b) Explain traversing the list, List operation, List slice L2 2 6 8

3|4
Q.No. Question BL CO PO Marks
Module-3
5 a) Write programs for searching, splitting, and replacing strings L3 3 12 8
based on pattern matching using regular expressions.
b) Discuss the following methods supported by compiled regular L2 3 12 8
expression objects.
a) search() b) match() c) findall()
OR
6 a) Write a program that accepts a sentence and calculate the number L3 3 3 8
of digits, uppercase and lowercase letters.
b) Explain the concepts of functions in brief L2 3 1 8
Module-4
7 a) Explain the character classes used in regular expression L2 4 4 8
b) Write a program to match the expression: L3 4 4 8
(i) sjec@ac.in.
(ii) Hello.all@gmail.com

OR
8 a) Differentiate greedy and non-greedy matching method L4 4 4 8
b) Discuss Pattern matching and regular expressions in brief L3 4 1 8
Module-5
9 a) Discuss the read and write mode on files. Write the program to L2 5 1 8
read and write contents to file
b) Write a python program to create 3 files file1.txt, file2.txt and L3 5 5 8
file3.txt in a folder. Write the content in file1.txt as “VTU” and in
file2.txt as “UNIVERSITY”. Open and merge contents of file1.txt
and file2.txt and write the merged content in file3.txt.
OR
10 a) Write a program to count number of lines and total number of L3 5 3 8
characters in given file
b) Discuss the methods of os.path module in brief L2 5 3 8

4|4

You might also like