A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. What is the type of each element in sys.argv?
a. set
b. list
c. tuple
d. string
View Answer Report Discuss Too Difficult!
Answer: (d).string

2. What is the length of sys.argv?
a. number of arguments
b. number of arguments + 1
c. number of arguments – 1
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).number of arguments + 1

3. What is the output of the following code?
def foo(k):
    k[0] = 1
q = [0]
foo(q)
print(q)
a. [0].
b. [1].
c. [1, 0].
d. [0, 1].
View Answer Report Discuss Too Difficult!
Answer: (b).[1].

4. How are keyword arguments specified in the function heading?
a. one star followed by a valid identifier
b. one underscore followed by a valid identifier
c. two stars followed by a valid identifier
d. two underscores followed by a valid identifier
View Answer Report Discuss Too Difficult!
Answer: (c).two stars followed by a valid identifier

5. How many keyword arguments can be passed to a function in a single function call?
a. zero
b. one
c. zero or more
d. one or more
View Answer Report Discuss Too Difficult!
Answer: (c).zero or more

6. What is the output of the following code?
def foo(fname, val):
    print(fname(val))
foo(max, [1, 2, 3])
foo(min, [1, 2, 3])
a. 3 1
b. 1 3
c. error
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).3 1

7. What is the output of the following code?
def foo():
    return total + 1
total = 0
print(foo())
a. 0
b. 1
c. error
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).1

8. What is the output of the following code?
def foo():
    total += 1
    return total
total = 0
print(foo())
a. 0
b. 1
c. error
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (c).error

9. What is the output of the following code?
def foo(x):
    x = ['def', 'abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
a. True
b. False
c. None
d. Error
View Answer Report Discuss Too Difficult!
Answer: (b).False

10. What is the output of the following code?
def foo(i, x=[]):
    x.append(i)
    return x
for i in range(3):
    print(foo(i))
a. [0] [1] [2].
b. [0] [0, 1] [0, 1, 2].
c. [1] [2] [3].
d. [1] [1, 2] [1, 2, 3].
View Answer Report Discuss Too Difficult!
Answer: (b).[0] [0, 1] [0, 1, 2].

Page 1 of 7