CSC 201 +++ by PAULTIMI
CSC 201 +++ by PAULTIMI
ES
A - Python is a high-level, interpreted, interactive and object-oriented
scripting language.
B - Python is designed to be highly readable.
C - It uses English keywords frequently where as other languages use
punctuation, and it has
CC
fewer syntactical constructions than other languages.
D - All of the above.+++
S
A - PYTHONPATH
B - PYTHONSTARTUP+++
C - PYTHONCASEOK
ES
D – PYTHONHOME
S
Q 10 - Which of the following data types is not supported in python?
A - Tuple
ES
B - Dictionary
C - Generics+++
D – List
CC
Q 11 - What is the output of print str if str = 'Hello World!'?
A - Hello World!+++
B - Error
C - str
D - None of the above.
SU
S
Q 15 - What is the output of print str * 2 if str = 'Hello World!'?
A - Hello World!Hello World!+++
B - Hello World! * 2
ES
C - Hello World!
D - None of the above.
Q 17- What is the output of print job[-3] + job[-6] if job = “school call”?
A-c
B – co
C – al +++
D – Error
ANS = C
Q 20 – if s = (“---A biro is a pen; but not all pens are biros---”). What is
the output of s.find(‘are’)?
A – 35
B – 37+++
S
C – 38
D–1
ES
Q 21 - if s = (“---A biro is a pen; but not all pens are biros---”). What is
the output of s.count(‘but’)?
A – 20
B – 21
CC
C – 1+++
D – 11
A – 38
B – 37
C – 39+++
D – 36
5
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 24 - matrix = [[45,23,7,-1],[56,22,51,89],[23,56,77,80]]. What is the output
of matrix[1][3]?
A – [[45,23,7,-1],[23,56,77,80]]
B – [[45,23,7,-1],[56,22,51,89],[23,56,77,80]]
C – 89+++
D – 51
S
B – 12,10,30,13
C – [12,10,30,13]+++
D – [13,12,10,30]
ES
Q 26 - What is the output of the following block of code?
D = {}
D[‘Apple’]=4
CC
D[‘Apple’]=8
print D
A – {‘Apple’:4}
B – [‘Apple’:8]
C – {‘Apple’:8}+++
SU
D – [‘Apple’:8]
E – {‘Apple’:4,’Apple’:8}
Q 28 - What is the output of print list if list = [ 'abcd', 786 , 2.23, 'john',
6
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
70.2 ]?
A - [ 'abcd', 786 , 2.23, 'john', 70.2 ]+++
B - list
C – ‘abcd’,786,2.23,’john’,70.2
D - None of the above.
Q 29 - What is the output of print list[0] if list = [ 'abcd', 786 , 2.23, 'john',
70.2 ]?
A - [ 'abcd', 786 , 2.23, 'john', 70.2 ]
B - abcd+++
C – ‘abcd’
D - None of the above.
S
ES
Q 30 - What is the output of print list[1:3] if list = [ 'abcd', 786 , 2.23,
'john', 70.2 ]?
A - [ 'abcd', 786 , 2.23, 'john', 70.2 ]
B – 786,2.23
C - [786, 2.23]+++
CC
D - None of the above.
Q 31 - What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john',
70.2 ]?
SU
Q 32 - What is the output of print [0:3] if list = [ 'abcd', 786 , 2.23, 'john',
70.2 ]?
A - [ 'abcd', 786 , 2.23, ]
B – ‘abcd’, 786, 2.23
C - Error+++
D – None of the above
7
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 33 - What is the output of print tinylist * 2 if tinylist = [123, 'john']?
A - [123, 'john', 123, 'john']+++
B - [123, 'john'] * 2
C - tinylisttinylist
D - None of the above.
S
C – [2,4,7,8,10]+++
D – [7,7,7,7,7]
ES
Q 35 - Which of the following is correct about tuples in python?
A - A tuple is another sequence data type that is similar to the list.
B - A tuple consists of a number of values separated by commas.
CC
C - Unlike lists, however, tuples are enclosed within parentheses.
D - All of the above.+++
S
A - Error
B – 786, 2.23
C – (786, 2.23)+++
ES
D - None of the above.
Q 43- Which of the following functions of dictionary gets all the keys
from the dictionary?
A - getkeys
B - key
C - keys+++
D - None of the above.
S
ES
Q 44 - Which of the following function of dictionary gets all the values
from the dictionary?
A - getvalues
B - value
C - values+++
CC
D - None of the above.
B – long(x[, base])
C – float(x)
D – str(x)
10
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 47 - Which of the following function convert a string to a float in python?
A – int(x[, base])
B – long(x[, base])
C – float(x)+++
D – str(x)
S
D – str(x)+++
ES
Q 49 - Which of the following function convert an object to a regular
expression in python?
A – repr(x)+++
B – eval(str)
CC
C – tuple(s)
D – list(s)
python?
A – repr(x)
B – eval(str)+++
C – tuple(s)
D – list(s)
S
B – dict(d)
C – frozenset(s)
D – chr(x)
ES
Q 54 - Which of the following function convert a sequence of tuples to
dictionary in
CC
python?
A – set(x)
B – dict(d)+++
C – frozenset(s)
D – chr(x)
SU
S
Q 58 - Which of the following function convert a single character to its
ES
integer value in python?
A – unichr(x)
B – ord(x)+++
C – hex(x)
D – oct(x)
CC
Q 59 - Which of the following function convert an integer to hexadecimal
string in python?
A – unichr(x)
SU
B – ord(x)
C – hex(x)+++
D – oct(x)
13
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 61 - Which of the following operator in python performs exponential
power calculation on operands?
A - **+++
B - //
C - is
D - not in
S
B - //+++
C - is
D - not in
ES
Q 63 - Which of the following operator in python evaluates to true if the
variables on either side of the operator point to the same object and false
CC
otherwise?
A - **
B - //
C - is+++
D - not in
SU
S
ES
Q 67 - Which of the following statement is used when a statement is
required syntactically but you do not want any command or code to
execute?
A - break
B - continue
CC
C - pass+++
D - None of the above.
tuple, or string?
A – choice(seq)+++
B - randrange ([start, ]stop[, step])
C – random()
D – seed([x])
Q 71 - Which of the following function sets the integer starting value used
in generating random numbers?
S
A – choice(seq)
B – randrange( [start, ]stop[, step])
C – random()
ES
D – seed([x])+++
S
Q 76 - Which of the following function checks in a string that all
characters are in lowercase?
ES
A – islower()+++
B – isnumeric()
C – isspace()
D – istitle()
CC
Q 77 - Which of the following function checks in a string that all
characters are numeric?
A – islower()
B – isnumeric()+++
C – isspace()
SU
D – istitle()
17
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 79 - Which of the following function checks in a string that all
characters are titlecased?
A – islower()
B – isnumeric()
C – isspace()
D – istitle()+++
S
D – ljust(width[, fillchar])
ANS = A
ES
Q 81 - Which of the following function merges elements in a sequence?
A – isupper()
B – join(seq)+++
C – len(string)
CC
D – ljust(width[, fillchar])
ANS = B
B – join(seq)
C – len(string)+++
D – ljust(width[, fillchar])
18
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 84 - Which of the following function converts a string to all lowercase?
A – lower()+++
B – lstrip()
C – max(str)
D – min(str)
S
C – max(str)
D – min(str)
ANS = B
ES
Q 86 - Which of the following function returns the max alphabetical
character from the string str?
A – cmp()
CC
B – lstrip()
C – max(str)+++
D – min(str)
SU
S
Q 90 - Which of the following function changes case for all letters in
string?
ES
A – replace(old, new[, max])
B – strip([chars])
C – swapcase()+++
D – title()
CC
Q 91 - Which of the following function returns title cased version of string?
A – replace(old, new[, max])
B – strip([chars])
C – swapcase()
SU
D – title()+++
S
Q 95 - What is the output of [1, 2, 3] + [4, 5, 6]?
A - [1, 2, 3, 4, 5, 6]+++
ES
B - [1, 2, 3],[4, 5, 6]
C - [5, 7,9]
D – 21
CC
Q 96 - What is the output of ['Hi!'] * 4?
A - ['Hi!', 'Hi!', 'Hi!', 'Hi!']+++
B - ['Hi!'] * 4
C - Error
D - None of the above.
SU
S
Q 100- What is the output of L[1:] if L = [1,2,3]?
A - 2,3+++
B-2
C-3
ES
D - None of the above.
CC
Q 101 - Which of the following functions compares elements of both lists?
A – cmp(list1, list2)+++
B - len(list1, list2)
C - max(list1, list2)
D - min(list1, list2)
SU
Q 102- Which of the following functions gives the total length of the list?
A – cmp(list)
B - len(list)+++
C - max(list)
D – min(list)
Q 103 – Which of the following functions returns item from the list with
max value?
22
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A - cmp(list)
B - len(list)
C - max(list)+++
D – min(list)
Q 104 – Which of the following functions returns item from the list with
min value?
A - cmp(list)
B - len(list)
C - max(list)
D – min(list)+++
S
Q 105 – Which of the following functions returns the lowest index in list
that obj appears?
ES
A - list.index(obj)+++
B - list.insert(index, obj)
C - list.pop(obj = list[ − 1])
D - list.remove(obj)
CC
Q 106 – Which of the following functions inserts an object at given index in
a list?
A - list.index(obj)
B - list.insert(index, obj)+++
SU
Q 107 – Whch of the following functions removes last object from a list?
A - list.index(obj)
B - list.insert(index, obj)
C - list.pop(obj = list[ − 1])+++
D - list.remove(obj)
S
A - list.reverse
B - list.sort([func])+++
C - list.pop(obj = list[ − 1])
ES
D - list.remove(obj)
24
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 114 – D1 = {"john":40,"peter":45}
D2 = d = {"john":456,"peter":45}
What is the output of D1 > D2?
A - No
B – True
C – False+++
D – Syntax Error
S
A[0] = 4
Print B
ES
A - [1, 2, 3]
B – [4,1,2,3]
C – [1,2,3,4]
D – [4,2,3]+++
CC
SU
25
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS