S
Q 1 - Which of the following is correct about Python?
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.+++
Q 2 - Which of the following is correct about Python?
SU
A - It supports functional and structured programming methods as well as
OOP.
B - It can be used as a scripting language or can be compiled to byte-code
for building large applications.
C - It provides very high-level dynamic data types and supports dynamic
type checking.
D - All of the above.+++
Q 3 - Which of the following is correct about Python?
A - It supports automatic garbage collection.
B - It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
C - Both of the above.+++
1
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
D - None of the above.
Q 4 - Which of the following environment variable for Python tells the
Python interpreter where to locate the module files imported into a
program?
A - PYTHONPATH+++
B - PYTHONSTARTUP
C - PYTHONCASEOK
D – PYTHONHOME
Q 5 - Which of the following environment variable for Python contains the
path of an initialization file containing Python source code?
S
A - PYTHONPATH
B - PYTHONSTARTUP+++
C - PYTHONCASEOK
ES
D – PYTHONHOME
Q 6 - Which of the following environment variable for Python is used in
CC
Windows to instruct Python to find the first case-insensitive match in an
import statement?
A - PYTHONPATH
B - PYTHONSTARTUP
C - PYTHONCASEOK+++
D – PYTHONHOME
SU
Q 7 - Which of the following environment variable for Python is an
alternative module search path?
A - PYTHONPATH
B - PYTHONSTARTUP
C - PYTHONCASEOK
D – PYTHONHOME+++
Q 8 - Is python a case sensitive language?
2
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A - true+++
B – false
C – can’t say
D – None of the above
Q 9 - Which of the following data types is not supported in python?
A - Numbers
B - String
C - List
D – Slice+++
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
Q 12 - What is the output of print str[0] if str = 'Hello World!'?
A - Hello World!
B - H+++
C - ello World!
D - None of the above.
Q 13 - What is the output of print str[2:5] if str = 'Hello World!'?
A - llo World!
3
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
B-H
C - llo+++
D - None of the above.
Q 14 - What is the output of print str[2:] if str = 'Hello World!'?
A - llo World!+++
B-H
C - llo
D - None of the above.
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 16 - What is the output of print job[-9] if job = “School Call”?
CC
A-c
B – h+++
C–o
D – Error
SU
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 18 - What is the output of print dept[16:3:-1] if dept = 'computer
science'?
A – ecneics retu+++
B – p cpe see
C – syntax error
D - mpu
4
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 19 - What is the output of print dept[0:16:3] if dept = 'computer
science'?
A – pesee
B – p cpe see
C – syntax error
D - cpesee+++
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
Q 22 - x = (“Federal University of Technology, Akure”). What is the output
of len(x)?
SU
A – 38
B – 37
C – 39+++
D – 36
Q 23 - x = (“Federal University of Technology, Akure”). What is the output
of x[2:10:2]?
A – drlU
B – ‘drlU’+++
C – drl U
D – drlUi
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
Q 25 - What is the output of the following?
L = [12,10,30]
L.append(13)
print L
A – 12,10,30
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 27 - What is the output of [‘box’]*3?
A – [‘box’][‘box’][‘box’]
B – [boxboxbox]
C – [‘box’,’box’,’box’]+++
D – [‘boxboxbox’]
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
A - [ 'abcd', 786 , 2.23, 'john', 70.2 ]
B - abcd
C - [786, 2.23]
D - [2.23, 'john', 70.2]+++
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.
Q 34 - What is the output of sample_List[2] = 7 if sample_List =
[2,4,6,8,10]?
A – [7,4,6,8,10]
B – [2,4,6,8,10] = 7
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.+++
Q 36 - What is the output of print list if tuple = ′abcd′, 786, 2.23,′john′,
70.2?
SU
A - ′abcd′, 786, 2.23, ′john′, 70.2+++
B - tuple
C - Error
D - None of the above.
Q 37 - What is the output of print tuple[0] if tuple = ′abcd′, 786,
2.23,′john′, 70.2?
A - ′abcd′, 786, 2.23, ′john′, 70.2
B - abcd+++
C – ‘abcd’
D - None of the above.
8
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 38 - What is the output of print tuple[1:3] if tuple = ′abcd′, 786, ‘john’,
2.23, 70.2?
A - 786, 'john'
B - (786, 'john')+++
C - Error
D - None of the above.
Q 39 - What is the output of print tuple[1:3] if tuple = ′abcd′, 786,
2.23,′john′, 70.2?
S
A - Error
B – 786, 2.23
C – (786, 2.23)+++
ES
D - None of the above.
Q 40 - What is the output of print tuple[2:] if tuple = ′abcd′, 786,
CC
2.23,′john′, 70.2?
A - 2.23, ‘john’, 70.2
B - abcd
C - 786, 2.23
D – (2.23, ′john′, 70.2)+++
SU
Q 41 - What is the output of print tinytuple * 2 if tinytuple = 123,′john′?
A – (123, ′john′, 123, ′john′)+++
B - 123, ′john′ * 2
C - Error
D - 123, ′john′, 123, ′john′
Q 42- Which of the following is correct about dictionaries in python?
A - Python's dictionaries are kind of hash table type.
B - They work like associative arrays or hashes found in Perl and consist of
9
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
key-value pairs.
C - A dictionary key can be almost any Python type, but are usually
numbers or strings. Values,
on the other hand, can be any arbitrary Python object.
D - All 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.
Q 45 - Which of the following function convert a string to an int in python?
A – int(x[, base])+++
SU
B – long(x[, base])
C – float(x)
D – str(x)
Q 46 - Which of the following function convert a string to a long in python?
A – int(x[, base])
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)
Q 48 - Which of the following function convert an object to a string in
python?
A – int(x[, base])
B – long(x[, base])
C – float(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)
Q 50 - Which of the following function convert a String to an object in
SU
python?
A – repr(x)
B – eval(str)+++
C – tuple(s)
D – list(s)
Q 51 - Which of the following function converts a String to a tuple in
python?
A – repr(x)
B – eval(str)
C – tuple(x)+++
11
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
D – list(x)
Q 52 - Which of the following functions convert a String to a list in python?
A – repr(x)
B – eval(str)
C – tuple(s)
D – list(s)+++
Q 53 - Which of the following functions convert a String to a set in python?
A – set(x)+++
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
Q 55 - Which of the following function convert a string to a frozen set in
python?
A – set(x)
B – dict(d)
C – frozenset(s)+++
D – chr(x)
Q 56 - Which of the following function convert an integer to a character in
python?
12
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A – set(x)
B – dict(d)
C – frozenset(s)
D – chr(x)+++
Q 57 - Which of the following function convert an integer to an unicode
character in python?
A – unichr(x)+++
B – ord(x)
C – hex(x)
D – oct(x)
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)
Q 60 - Which of the following function convert an integer to octal string in
python?
A – unichr(x)
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
Q 62 - Which of the following operator in python performs the division on
operands where the result is the quotient in which the digits after the
decimal point are removed?
A - **
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
Q 64 - Which of the following operator in python evaluates to true if it
does not finds a variable in the specified sequence and false otherwise?
A - **
B - //
C - is
D - not in+++
Q 65 - Which of the following statement terminates the loop statement
and transfers execution to the statement immediately following the loop?
14
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A - break+++
B - continue
C - pass
D - None of the above.
Q 66 - Which of the following statement causes the loop to skip the
remainder of its body and immediately retest its condition prior to
reiterating?
A - break
B - continue+++
C - pass
D - None of the above.
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.
Q 68 - Which of the following function returns a random item from a list,
SU
tuple, or string?
A – choice(seq)+++
B - randrange ([start, ]stop[, step])
C – random()
D – seed([x])
Q 69 - Which of the following function returns a randomly selected
element from range?
A – choice(seq)
B – randrange( [start, ]stop[, step])+++
C – random()
D – seed([x])
15
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 70 - Which of the following function returns a random float r, such that
0 is less than or equal to r and r is less than 1?
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])+++
Q 72 - Which of the following function randomizes the items of a list in
CC
place?
A – shuffle(lst)+++
B – capitalize()
C – isalnum()
D – isdigit()
SU
Q 73 - Which of the following function capitalizes first letter of string?
A – shuffle(lst)
B – capitalize()+++
C – isalnum()
D – isdigit()
Q 74 - Which of the following function checks in a string that all
characters are alphanumeric?
A – shuffle(lst)
16
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
B – capitalize()
C – isalnum()+++
D – isdigit()
Q 75 - Which of the following function checks in a string that all
characters are digits?
A – shuffle(lst)
B – capitalize()
C – isalnum()
D – isdigit()+++
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()
Q 78 - Which of the following function checks in a string that all
characters are whitespaces?
A – islower()
B – isnumeric()
C – isspace()+++
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()+++
Q 80 - Which of the following function checks in a string that all
characters are in uppercase?
A – isupper()+++
B – join(seq)
C – len(string)
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
Q 82 - Which of the following function gets the length of the string?
A – isupper()
SU
B – join(seq)
C – len(string)+++
D – ljust(width[, fillchar])
Q 83 - Which of the following function gets a space-padded string with
the original string left-justified to a total of width columns?
A – isupper()
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)
Q 85 - Which of the following function removes all leading whitespace in
string?
A – lower()
B – lstrip()+++
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
Q 87 - Which of the following function returns the min alphabetical
character from the string str?
A – cmp()
B – lstrip()
C – max(str)
D – min(str)+++
Q 88 - Which of the following function replaces all occurrences of old
substring in string with new string?
A – replace(old, new[, max])+++
B – strip([chars])
19
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
C – swapcase()
D – title()
Q 89 - Which of the following function removes all leading and trailing
whitespace in string?
A – replace(old, new[, max])
B - strip[chars]+++
C – swapcase()
D – title()
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()+++
Q 92 - Which of the following function converts a string to all uppercase?
A – upper()+++
B – isdecimal()
C – swapcase()
D – title()
Q 93 - Which of the following function checks in a string that all
20
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
characters are decimal?
A – upper()
B – isdecimal()+++
C – swapcase()
D – title()
Q 94 - What is the output of len([1, 2, 3])?
A-1
B-2
C - 3+++
D-4
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
Q 97 - What is the output of 3 in [1, 2, 3]?
A - true+++
B - false
C - Error
D - None of the above.
Q 98 - What is the output of L[2] if L = [1,2,3]?
21
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A-1
B-2
C - 3+++
D - None of the above.
Q 99 - What is the output of L[-2] if L = [1,2,3]?
A-1
B - 2+++
C-3
D - None of the above.
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
C - list.pop(obj = list[ − 1])
D - list.remove(obj)
ANS = B
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)
Q 108- Which of the following functions removes an object from a list?
23
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A - list.index(obj)
B - list.insert(index, obj)
C - list.pop(obj = list[ − 1])
D - list.remove(obj)+++
Q 109 – Which of the following functions reverses objects of list in place?
A - list.reverse+++
B - list.sort([func])
C - list.pop(obj = list[ − 1])
D - list.remove(obj)
Q 110- Which of the following functions sorts a list?
S
A - list.reverse
B - list.sort([func])+++
C - list.pop(obj = list[ − 1])
ES
D - list.remove(obj)
Q 111 – Which of the following functions compares elements of both
dictionaries dict1, dict2?
CC
A - dict1.cmp(dict2)
B - dict1.sort(dict2)
C – cmp(dict1, dict2)+++
D - None of the above.
SU
Q 112 – Which of the following functions compares elements of both
dictionaries dict1, dict2?
A – max(dict)
B – min(dict)
C – len(dict)+++
D - None of the above.
Q 113 – What is the output of print ("ccbdcdcb".find("c"))
A–4
B–1
C – 0+++
D – None
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
Q 115 – What will be the output of the program below?
A = [1,2,3]
B=A
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