1. How many CPUs will the threading library use?
A. Zero. threading does not make use of CPUs.
B. One
C. Two
D. All available CPUs
2.def REVERSE(L):
L.reverse()
return (L)
def YKNJS(L)
list = []
list.extend(Rev(L))
print(list)
L = [1,3.1,5,31,7.531]
YKNJS(L)
A.[1,4.1,2.31,7.531]
B.[1,3.1,5.31,7.531]
C.[7.531,5.31,3.1,1]
D. None of these
3.Which of the following codes raises an exception?
A. #test
B. a={1, 2, \ #comment 3, 4}
C. a={1, 2, #comment 3, 4}
4.Which collection type is used to associate values with unique keys?
A.slot
B.dictionary
3.queue
4.sorted list
5.What will this code print?
>>> a=7
>>> print(a+1)
A. 8
B. a + 1
C. This code will raise an exception
D. None of the above
6.What is key difference between a set and a list ?
A. A set is an ordered collection unique items.A list is an unordered collectio of non-unique items
B. Elements can be retrived from a list but they cannot be retrived from a set.
C. A set is an ordered collection of non-unique items.A list is an unordered collection of unique items.
D.A set is an unordered collection unique items.A list is an ordered collection of non-unique items.
7.What is the maximum value for an integer in Python 3?
A. 2^63-1
B. 32767
C. 65536
D. No limit
8.How do you denote the end of a block in Python 3?
A. By indenting the next line less than the current
B. With a semicolon }
C. With the end keyword
D. With a backslash \
9.def addToList(listcontainer):
listcontainer+=[10]
mylistContainer = [10,20,30,40]
addToList(mylistContainer)
print(len(mylistContainer))
A.4
B.5
C.6
D.Compiler Error
10.According to the PEP 8 coding style guidelines,how should constant values be named in Python?
A.in camel case without using underscores to separate words --eg.maxValue = 255
B. in lowercase with underscores to separate words --e.g.max_value=255
C.in all caps with underscores separating words --eg. MAX_VALUE=255
D.in mixed case without using underscores to seperate words --eg.MaxValue=255
11.In this list, how will you access the letter ‘t’ in ‘bat’?
list = [1, [‘a’, ‘b’, [‘kill’, ‘bat’, ‘cup’], ‘c’], 3]
A. list[1, 2, 1, 2]
B. list[2][1][2]
C. list[1][2][1][2]
D. list[1][2][1]
12.How will you turn the list a = [1, 2, 7, 8] into [1, 2, 3, 4, 5, 6, 7, 8]?
Please select 2 correct answers
A. a[2:2] = [3, 4, 5, 6]
B. a[2:3] = [3, 4, 5, 6, 7]
C. a[2:2] = [3, 4, 5, 6, 7]
D. a[2:3] = [3, 4, 5, 6]
13.What is the value of y?
>>> x, y, z = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[2::3]
A. 2
B. 5
C. 6
D. This code raises an exception
14.What is the result of {1, 2, 3} & {4, 5, 6}?
A. {}
B. set()
C. {1, 2, 3, 4, 5, 6}
D. None of the above
15.what is the correct syntax for creating a variable that is bound to a set?
A.myset = {0,'apple',3.5}
B.myset = to_set(0,'apple',3.5)
C.myset = (0,'apple',3.5).to_set()
D.myset = (0,'apple',3.5).set()
16.What statement about static methods is true?
A. Static methods are called static because they always return None.
B. Static methods can be bound to either a class or an instance of a class.
C.static methods server mostly as utility methods or helper methods,since they can't access or modify a class's state.
D.Static methods can access and modify the state of a class or an instance of a class.
17.Which statements delete the value ‘milk’ from the set s = {‘milk’, ‘cheese’, ‘butter’, ‘buttermilk’}?
Please select 4 correct answers
A. s.discard(‘milk’)
B. del s[‘milk’]
C. s -= ‘milk’
D. s -= {‘milk’}
E. s &= {‘cheese’, ‘butter’, ‘buttermilk’}
F. s.difference_update({‘milk’})
G. s.pop()
18.In the following code, how many objects and references does Python create?
name = ‘Ayushi’
fname = name
A. One object, one reference
B. One object, two references
C. Two objects, one reference
D. Two objects, two references
19.According to PEP 8, what case should you use for variable names with more than one word?
A. Camel case
B. Pascal case
C. Snake case
D. Kebab case
E. Upper case with snake case
20.x = ['ab','cd']
for i in x:
i.upper()
print(x)
A. Error
B. ['cd','ab']
C. ['ab','cd']
D. None of these
21.Which of these is NOT a characteristics of namedtuples?
A. You can assign a name to each of the namedtuple members and refer to them that way,similarly to how you would access keys in dictionary.
B.Each member of a namedtuple object can be indexed to directly,just like in a regular tuple
C.namedtuples are just as memory efficient as regular tuples
D.No import is needed to use namedtuples because they are available in the standard library.
22.What is the output of the following code?
>>> nums = [[val for val in range(num)] for num in range(3)]
>>> for num in nums:
for val in num:
if val < 2:
print(‘*’, end=”)
A. *
B. **
C. ***
D. ****
23.What is the output of this code?
a,b=1,0
a=a^b
b=a^b
a=a^b
print(a)
A. 0
B. 1
C. 2
D. This code will raise a runtime error
24.from math import *
a = 2.13
b = 3.7777
c = -3.12
print(int(a),floor(b),ceil(c),fabs(c))
A. 24-3 3
B. 2 3-3 3.12
C. 2 2-3 3.12
D.Error
25.What is the value of this expression?
2**2**3**1
A. 12
B. 64
C. 128
D. 256
26.Why would you use a virtual environment?
A. Virtual environment create a "bubble" around your project so that any libraries or packages you install within it don't affect your entire machine.
B.Teams with remote employees use virtual environments so they can share code,do code reviews,and collaorate remotely.
C. Virtual environments were common in Python 2 because they augmented missing features in the language.Virtual environments are not necessary in Python 3 due to advancement in the language.
D.Virtual environments are tied to your Github or Bitbucket account,allowing you to access of your repos virtually from any machine
27.What is the output of the following Python Programs
D = dict()
for x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7]=x[0]
print(D)
A. {1:1,7:2,0:1,8:1}
B. KeyError
C. {0:0,7:0,1:1,8:1}
D. {0:1,7:0,1:1,8:0}
28.How will you open a file for reading as a text file?
Please select 2 correct answers
A. open('file.txt')
B. open('file.txt', 'r’)
C. open('file.txt', w’)
D. open('file.txt', 'b’)
29.Suppose you have two sets s1 = {1, 2, 3} and s2 = {3, 4, 5}. Which of the following statements give us their union?
Please select 5 correct answers
s1.union({3, 4, 5})
s1 | {3, 4, 5}
s1.union([3, 4, 5])
s1 | [3, 4, 5]
s1.union(set([3, 4, 5]))
s1 | set([3, 4, 5])
30.Polymorphism is when a subclass can modify the behavior of its superclass.
A. False
B. True
C. Depends on the contents of the class
D. This is an invalid question
32.What will be the output of the following code?
33.What is the output of the following code?
34.What is the output of the following code?
35.What is the output of the following Python Programs?
36.List = [True,50,10]
37.What is the output of this code?
38.In the following code, how will you get to the value 7?
40.In the following code, what is the output?
41.def test():
43.Which of the following return True for a string?
44.What is the value of round(12.5) – round(11.5)?
46.Select the correct output for this code:
48.Assuming the node is in a singly linked list,what is the runtime complexity of searching for a specific node within a singly linked list?
49.What is the runtime complexity of searching for an item in a binary search tree?
50.What is the value of this expression?