0% found this document useful (0 votes)
3 views26 pages

+++ csc201

The document contains a series of multiple-choice questions related to Python programming, covering topics such as language features, data types, environment variables, and built-in functions. Each question provides several options, with the correct answer indicated by '+++'. The content is structured as a quiz format, likely intended for educational purposes.

Uploaded by

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

+++ csc201

The document contains a series of multiple-choice questions related to Python programming, covering topics such as language features, data types, environment variables, and built-in functions. Each question provides several options, with the correct answer indicated by '+++'. The content is structured as a quiz format, likely intended for educational purposes.

Uploaded by

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

Q 1 - Which of the following is correct about Python?

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
fewer syntactical constructions than other languages.
D - All of the above.+++

Q 2 - Which of the following is correct about Python?


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?
A - PYTHONPATH
B - PYTHONSTARTUP+++
C - PYTHONCASEOK
D – PYTHONHOME

Q 6 - Which of the following environment variable for


Python is used in Windows to instruct Python to find the
first case-insensitive match in an import statement?
A - PYTHONPATH
B - PYTHONSTARTUP
C - PYTHONCASEOK+++
D – PYTHONHOME

Q 7 - Which of the following environment variable for


Python is an alternative module search path?
A - PYTHONPATH
B - PYTHONSTARTUP
C - PYTHONCASEOK
D – PYTHONHOME+++

2
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 8 - Is python a case sensitive language?
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+++

Q 10 - Which of the following data types is not


supported in python?
A - Tuple
B - Dictionary
C - Generics+++
D – List

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.

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.
3
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 13 - What is the output of print str[2:5] if str = 'Hello
World!'?
A - llo World!
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.

Q 15 - What is the output of print str * 2 if str = 'Hello


World!'?
A - Hello World!Hello World!+++
B - Hello World! * 2
C - Hello World!
D - None of the above.

Q 16 - What is the output of print job[-9] if job = “School


Call”?
A-c
B – h+++
C–o
D – Error

Q 17- What is the output of print job[-3] + job[-6] if job


= “school call”?
A-c
B – co
4
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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

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+++
C – 38
D–1

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
C – 1+++
D – 11

Q 22 - x = (“Federal University of Technology, Akure”).


What is the output of len(x)?
A – 38
B – 37
C – 39+++
5
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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

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
B – 12,10,30,13
C – [12,10,30,13]+++
D – [13,12,10,30]

Q 26 - What is the output of the following block of


code?
D = {}
D[‘Apple’]=4
D[‘Apple’]=8
print D

A – {‘Apple’:4}
B – [‘Apple’:8]
C – {‘Apple’:8}+++
D – [‘Apple’:8]
E – {‘Apple’:4,’Apple’:8}
6
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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', 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.

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]+++
D - None of the above.

Q 31 - What is the output of print list[2:] if list =


[ 'abcd', 786 , 2.23, 'john', 70.2 ]?
A - [ 'abcd', 786 , 2.23, 'john', 70.2 ]
B - abcd
7
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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

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
C – [2,4,7,8,10]+++
D – [7,7,7,7,7]

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.
C - Unlike lists, however, tuples are enclosed within
parentheses.
D - All of the above.+++

8
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 36 - What is the output of print list if tuple = ′abcd′,
786, 2.23,′john′, 70.2?
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.

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?
A - Error
B – 786, 2.23
C – (786, 2.23)+++
D - None of the above.

Q 40 - What is the output of print tuple[2:] if tuple =


′abcd′, 786, 2.23,′john′, 70.2?
A - 2.23, ‘john’, 70.2
B - abcd
9
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
C - 786, 2.23
D – (2.23, ′john′, 70.2)+++

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 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.

Q 44 - Which of the following function of dictionary gets


all the values from the dictionary?
A - getvalues
B - value
C - values+++
D - None of the above.
10
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 45 - Which of the following function convert a string
to an int in python?
A – int(x[, base])+++
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)

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)
D – str(x)+++

Q 49 - Which of the following function convert an object


to a regular expression in python?
11
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A – repr(x)+++
B – eval(str)
C – tuple(s)
D – list(s)

Q 50 - Which of the following function convert a String


to an object in 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)+++
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)+++
B – dict(d)
C – frozenset(s)
D – chr(x)

12
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 54 - Which of the following function convert a
sequence of tuples to dictionary in
python?
A – set(x)
B – dict(d)+++
C – frozenset(s)
D – chr(x)

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?
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)

Q 58 - Which of the following function convert a single


character to its integer value in python?
13
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A – unichr(x)
B – ord(x)+++
C – hex(x)
D – oct(x)

Q 59 - Which of the following function convert an integer


to hexadecimal string in python?
A – unichr(x)
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)+++

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 - **
B - //+++
C - is
D - not in
14
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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 otherwise?
A - **
B - //
C - is+++
D - not in

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?
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.

15
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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
C - pass+++
D - None of the above.

Q 68 - Which of the following function returns a random


item from a list, 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])

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?

16
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
A – choice(seq)
B – randrange( [start, ]stop[, step])
C – random()
D – seed([x])+++

Q 72 - Which of the following function randomizes the


items of a list in place?
A – shuffle(lst)+++
B – capitalize()
C – isalnum()
D – isdigit()

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)
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()+++

17
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 76 - Which of the following function checks in a string
that all characters are in lowercase?
A – islower()+++
B – isnumeric()
C – isspace()
D – istitle()

Q 77 - Which of the following function checks in a string


that all characters are numeric?
A – islower()
B – isnumeric()+++
C – isspace()
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()

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)
18
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
C – len(string)
D – ljust(width[, fillchar])
ANS = A

Q 81 - Which of the following function merges elements


in a sequence?
A – isupper()
B – join(seq)+++
C – len(string)
D – ljust(width[, fillchar])
ANS = B

Q 82 - Which of the following function gets the length of


the string?
A – isupper()
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])+++

Q 84 - Which of the following function converts a string


to all lowercase?
A – lower()+++
B – lstrip()
C – max(str)
D – min(str)

19
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 85 - Which of the following function removes all
leading whitespace in string?
A – lower()
B – lstrip()+++
C – max(str)
D – min(str)
ANS = B

Q 86 - Which of the following function returns the max


alphabetical character from the string str?
A – cmp()
B – lstrip()
C – max(str)+++
D – min(str)

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])
C – swapcase()
D – title()

Q 89 - Which of the following function removes all


leading and trailing whitespace in string?
A – replace(old, new[, max])
20
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
B - strip[chars]+++
C – swapcase()
D – title()

Q 90 - Which of the following function changes case for


all letters in string?
A – replace(old, new[, max])
B – strip([chars])
C – swapcase()+++
D – title()

Q 91 - Which of the following function returns title cased


version of string?
A – replace(old, new[, max])
B – strip([chars])
C – swapcase()
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 characters are decimal?
A – upper()
B – isdecimal()+++
C – swapcase()
D – title()

21
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
Q 94 - What is the output of len([1, 2, 3])?
A-1
B-2
C - 3+++
D-4

Q 95 - What is the output of [1, 2, 3] + [4, 5, 6]?


A - [1, 2, 3, 4, 5, 6]+++
B - [1, 2, 3],[4, 5, 6]
C - [5, 7,9]
D – 21

Q 96 - What is the output of ['Hi!'] * 4?


A - ['Hi!', 'Hi!', 'Hi!', 'Hi!']+++
B - ['Hi!'] * 4
C - Error
D - None of the above.

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]?


A-1
B-2
C - 3+++
D - None of the above.

22
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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.

Q 100- What is the output of L[1:] if L = [1,2,3]?


A - 2,3+++
B-2
C-3
D - None of the above.

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)

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?
A - cmp(list)
B - len(list)
C - max(list)+++
D – min(list)

23
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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)+++

Q 105 – Which of the following functions returns the


lowest index in list that obj appears?
A - list.index(obj)+++
B - list.insert(index, obj)
C - list.pop(obj = list[ − 1])
D - list.remove(obj)

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)+++
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?
A - list.index(obj)
B - list.insert(index, obj)
C - list.pop(obj = list[ − 1])
24
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS
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?


A - list.reverse
B - list.sort([func])+++
C - list.pop(obj = list[ − 1])
D - list.remove(obj)

Q 111 – Which of the following functions compares


elements of both dictionaries dict1, dict2?
A - dict1.cmp(dict2)
B - dict1.sort(dict2)
C – cmp(dict1, dict2)+++
D - None of the above.

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

25
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
A[0] = 4
Print B

A - [1, 2, 3]
B – [4,1,2,3]
C – [1,2,3,4]
D – [4,2,3]+++

26
COMPILED BY “OLUGBENGA” CONTACT 07035617005 FOR COMMENTS

You might also like