Which of the following is not a complex number?
AnswerWhat is the output of the following program :
print 0.1 + 0.2 == 0.3
Answer
Which module in Python supports regular expressions?
AnswerGiven a function that does not return any value, what value is shown when executed at the shell?
AnswerWhat is the output of the following program :
print "Hello World"[::-1]
Answer
What is the output of the following program :
i = 0
while i < 3:
print i
i++
print i+1
Answer
Which operator is overloaded by the or() function?
AnswerWhich function overloads the >> operator?
AnswerWhat is the output of the following code :
print 9//2
Answer
time.time() returns ________
AnswerSuppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
AnswerWhat is the output of the following program :
import re
sentence = 'horses are fast'
regex = re.compile('(?P\w+) (?P\w+) (?P\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
Answer
Which of the following is the use of id() function in python?
AnswerWhat is called when a function is defined inside a class?
AnswerWhat is the output of the following program :
y = 8
z = lambda x : x * y
print z(6)
Answer
What is the output of the following segment :
chr(ord('A'))
Answer
What is the output of the following code :
L = ['a','b','c','d']
print "".join(L)
Answer
What will be the output of the following code :
print type(type(int))
A certain computation generates two arrays a and b such that a[i]=f(i) for 0 ≤ i < n and b[i]=g(a[i]) for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.
Process X: Process Y:
private i; private i;
for (i=0; i < n; i++) { for (i=0; i < n; i++) {
a[i] = f(i); EntryY(R, S);
ExitX(R, S); b[i]=g(a[i]);
} }
Which one of the following represents the CORRECT implementations of ExitX and EntryY?
(A)
ExitX(R, S) {
P(R);
V(S);
}
EntryY (R, S) {
P(S);
V(R);
}
(B)
ExitX(R, S) {
V(R);
V(S);
}
EntryY(R, S) {
P(R);
P(S);
}
(C)
ExitX(R, S) {
P(S);
V(R);
}
EntryY(R, S) {
V(S);
P(R);
}
(D)
ExitX(R, S) {
V(R);
P(S);
}
EntryY(R, S) {
V(S);
P(R);
}
Answer
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?
Answer© 2017 QuizBucket.org