Python 3 - Mock Test IV
Q 1 - 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()
Q 2 - 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 3 - Which of the following function returns titlecased version of string?
A - replace(old, new [, max])
B - strip([chars])
C - swapcase()
D - title()
Q 4 - Which of the following function converts a string to all uppercase?
A - upper()
B - isdecimal()
C - swapcase()
D - title()
Q 5 - Which of the following function checks in a string that all characters are decimal?
A - upper()
B - isdecimal()
C - swapcase()
D - title()
Q 6 - What is the output of len([1, 2, 3])?
A - 1
B - 2
C - 3
D - 4
Q 7 - 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 8 - What is the output of ['Hi!'] * 4?
A - ['Hi!', 'Hi!', 'Hi!', 'Hi!']
B - ['Hi!'] * 4
C - Error
D - None of the above.
Q 9 - What is the output of 3 in [1, 2, 3]?
A - true
B - false
C - Error
D - None of the above.
Q 10 - What is the output of for x in [1, 2, 3]: print x?
A - x x x
B - 1 2 3
C - Error
D - None of the above.
Q 11 - What is the output of L[2] if L = [1,2,3]?
A - 1
B - 2
C - 3
D - None of the above.
Q 12 - What is the output of L[-2] if L = [1,2,3]?
A - 1
B - 2
C - 3
D - None of the above.
Q 13 - 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 14 - What is the following function compares elements of both lists?
A - cmp(list1, list2)
B - len(list1, list2)
C - max(list1, list2)
D - min(list1, list2)
Q 15 - What is the following function gives the total length of the list?
A - cmp(list)
B - len(list)
C - max(list)
D - min(list)
Q 16 - What is the following function returns item from the list with max value?
A - cmp(list)
B - len(list)
C - max(list)
D - min(list)
Q 17 - What is the following function returns item from the list with min value?
A - cmp(list)
B - len(list)
C - max(list)
D - min(list)
Q 18 - What is the following function 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 19 - What is the following function 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)
Q 20 - What is the following function 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 21 - What is the following function removes an object from a list?
A - list.index(obj)
B - list.insert(index, obj)
C - list.pop(obj=list[-1])
D - list.remove(obj)
Q 22 - What is the following function reverses objects of list in place?
A - list.reverse()
B - list.sort([func])
C - list.pop(obj=list[-1])
D - list.remove(obj)
Q 23 - What is the following function sorts a list?
A - list.reverse()
B - list.sort([func])
C - list.pop(obj=list[-1])
D - list.remove(obj)
Q 24 - What is the following function 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 25 - What is the following function compares elements of both dictionaries dict1, dict2?
A - max(dict)
B - min(dict)
C - len(dict)
D - None of the above.
Question NumberAnswer Key
1
B
2
C
3
D
4
A
5
B
6
C
7
A
8
A
9
A
10
B
11
C
12
A
13
A
14
A
15
B
16
C
17
D
18
A
19
B
20
C
21
D
22
A
23
B
24
C
25
C
https://www.tutorialspoint.com/python3/python_mock_test.htm?min=76&max=100
发表评论