ASSIGNMENT 2020
6st Semester
Discipline: ..BACHELOR OF COMPUTER APPLICATION .
Course Name:..PROGRAMMING IN PYTHON.
Course Code: .BCAH601.
Full Marks: 20 Time :
Q.No Marks
The figures in the right hand margin indicate full marks.
Candidates are required to give their answers in their own words as far as practicable .
Illustrate the answers wherever necessary .
[20X1=20]
1. Answer any 20 questions.
a. Which of the following is not a data type?
1.String 2. Numeric
3.Array 4. Tuple.
b. Which of the following will be printed?
X=4.5
Y=2
Print X//Y.
i)2.0 ii) 2.25
iii)0.25 iv) 0.5
c. Whats get printed?
nums=set([1,1,2,3,3,3,4])
print len(nums)
i)2 ii) 4
iii)5 iv) 7
d. Which file contains the predefined Python codes?
i)Function ii)Pi
iii)module iv)lambda
e. Which keyword is used to create an anonymous function?
i) Def ii) lambda
iii) Func iv) pi.
f. What will the output of the following code?
Def sqr(a):
return a*a
a = sqr(4)
i) 4 ii) 16 iii) 8 iv) none
g. What will be the output of the given code?
>>>”h”+”lm”
i)h ii)”hlm” iii)lm iv) hlm
Q.No Marks
h. Which one of the following functions replaces all occurrences of old substring in
string with new string?
i)replace(new, old[,max]) ii)replace(old, new[,max])
iii) replace(old, new[max]) iv) replace(new, old[max])
i. What will be output of the given ?
list=[1, 2, 3, 4, 10]
>>> print (list[-1])
i) 1 ii) 10 iii) 4 iv)error
j. Which of the following functions will give the total length of a list?
i) Len ii) len(list) iii) max(len) iv) max len(list)
k. Which of the following functions is used to return a tuple to a list.
i) list(seq) ii) seq(list) iii) list(tuple) iv) tuple(list)
l. Which of the following will not be correct if tuple=(10, 12, 14, 16, 18)?
i) print(min(tuple) ii) print(max(tuple)) iii) tuple[4]=20.
m. Which of the following functions in Python is used to convert a string into a tuple?
i) tuple(str) ii) str(tuple) iii) repr(tuple) iv) list(tuple)
n. Which of the following represent keys in the dictionary?
i) Function or list ii) numbers of list iii) numbers of string
o. What will be output of the following code?
dict = {‘name’ : ‘ravi’, ‘age’ : 35}
‘ravi’ in dict
i) True ii) False iii) error iv) none
p. Which of the following functions of the dictionary gets all the values from the dictionary?
i)dict.values() ii) dict.value() iii) getvalues() iv) getvalue()
q. Which of the following is the default mode while opening a file?
i)binary ii)number iii)text iv) none
r. Which of the following is incorrect when we use the binary mode ?
i)image files ii)text files iii) exe files iv) non-text file
s. What will be used to open a file in C:/xyz.txt for reading?.
i)f = open(“C:/xyz.txt”) ii)f=open(“C:\xyz.txt”) iii) f = open(“C:/xyz.txt, ‘r’)
t. At what position will the pointer be placed whenever we open a file for reading or writing?
i)middle ii) beginning iii) second line iv) end
.
u. Which module does python provide to perform operations like renaming and deleting files?
i)is ii) os iii) op iv) ip
v. Which of the following is not an attribute of a file in python?
i)name ii) name iii)delete iv)closed
w. Suppose p is python. What is p.upper()?
i)Python ii) PYTHON iii) python iv) PyTHon
x. What is the output of the following code?
print(type((‘Asansol’, ‘Durgapur’, ‘Burdwan’)))
i) <class, ‘set’> ii) <class, ‘list’> iii) <class, ‘dict’> iv)<class, ‘tuple’>
y. def MyFunction():
“Python is an interesting language”
return 1
print(MyFunction.__doc__[10:12])
What will be the output?
i) is ii) an iii) te iv) er