0% found this document useful (0 votes)
41 views

Python Paper

The document contains a 10 question Python programming exam with multiple choice and code writing questions. It asks the student to provide the output of given code snippets, find and correct errors in code, and write Python programs to solve problems such as finding the second lowest mark in a list of numbers and replacing substrings in a string.

Uploaded by

Nimisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Python Paper

The document contains a 10 question Python programming exam with multiple choice and code writing questions. It asks the student to provide the output of given code snippets, find and correct errors in code, and write Python programs to solve problems such as finding the second lowest mark in a list of numbers and replacing substrings in a string.

Uploaded by

Nimisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

KADI SARVA VISHWAVIDHYALAYA

B.E. Semester VI (CE/IT)


Python Programming (CE 605-3 / IT 605-3)
Re-Mid Semester Examination – April – 2019
Date: 03/04/19 Max. Marks: 30
Time: 1.30 Hrs
Instruction: (1) All questions are Compulsory.
(2) Figure to the right indicates full marks.

Q. I Give output of following code.


1. l1 = [ 1, 2, 3, 4 ] [2] 2. L = [3, 1, 2, 4] [2]
l2 = l1 T = (97, 'b', 101, 109)
l2.append(5) L.sort()
print l1, l2 counter = 0
for x in T:
l2 = l1[ ::-1] L[counter] += x
l2.append(6) counter += 1
print l1, l2 break
print(L)
3. print ( list( filter(lambda x : x%2 , range(-10,11) ) ) ) [2]
4. a ={} [2]
dict = a.fromkeys(['a', 'b', 'c', 'd'], 98)
print (a)
print (dict)
5. t = (1, (9, 5), 7, 2) [2]
a, b, c, d = t
print (b[1])
6. L = [4, 'a', False, 87] [2] 7. L = list('123456') [2]
T = (6, 'boy', True, 554) L[0] = L[5] = 0
for i in range(len(L)): L[3] = L[-2]
if L[i]: print(L)
L[i] = L[i] + T[i]
else:
break
print (L)
8. tuple = {} [2]
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)
9. names1 = ['Amir', 'Barry', 'Chales', 'Dao'] [2]

1|Page
names2 = [name.lower() for name in names1]
print (names2[2][0])
10. L1 = [1, 1.33, 'GFG', 0, 'NO', None, 'G', True] [2]
val1, val2 = 0, ''
for x in L1:
if(type(x) == int or type(x) == float):
val1 += x
elif(type(x) == str):
val2 += x
else:
break
print(val1, val2)
Q. II Find out error(s) if any in the following code and correct it.
Also give the output
1. a = [ 1, [ 2, [3, 4 ] ] , 5 ] [2]
a[0].extend([8,8,8,8,8])
p = a[1].append(8)
print (a)
print(p)
2. developers = set(['Me', 'You', 'False', 'True']) [2]
developers.remove( ['Me'] )
developers.remove( 'YOU' )
print (developers)
Q. III Write Python program for the following.
1. Ask user to enter the marks for each student, store them in a list [6]
and print the second lowest mark.
example
[1,0,0,1,-1,8] -> 0
[5,4,4,4,4,4,4] -> 5
[1,1,5,2,4,1,1,2] -> 2
[4,4,4,4,4,4,4] -> 0
OR
1. Given a string, find the first appearance of the substring 'not' and [6]
'bad'.
If the 'bad' follows the 'not', replace the whole 'not'...'bad'
substring with 'good'.
Return the resulting string.
Example :
This dinner is not that bad! → This dinner is good!
This tea is not hot → This tea is not hot
not not bad bad → good bad

2|Page

You might also like