Computer Science MCQ Xii
Computer Science MCQ Xii
(A) //
(B) ''
(C) /**/
(D) #
(A) function
(B) def
(C) method
(D) All of these
QNO3 Which of the following is correct way to declare string variable in Python?
QNO6 How to find the last element of list in Python? Assume `bikes` is the name of list.
(A) bikes[0]
(B) bikes[-1]
(C) bikes[lpos]
(D) bikes[:-1]
QNO7 If a='cpp', b='buzz' then which of the following operation would show 'cppbuzz' as
output?
(A) a+b
(B) a+''+b
(C) a+""+b
(D) All of the above
1
QNO8 If a='cpp', b='buzz' then what is the output of:
c = a-b
print(c)
(A) cpp-buzz
(B) cppbuzz
(C) TypeError: unsupported operand
(D) None of the above
QNO9 a = 8.6
b=2
print a//b
(A) 4.3
(B) 4.0
(C) 4
(D) compilation error
QNO 10
a = True
b = False
c = True
if not a or b:
print "a"
elif not a or not b and c:
print "b"
elif not a or b or not b and a:
MCQS CLASS 12
print "c"
else:
print "d"
(A) a
(B) b
(C) c
(D) d
2
Ans. Method Study
4. A small packet of shampoo is given free along with the purchase of soap.
Name the sales promotion technique.
Ans. Free Samples
5. To measure the level of knowledge and proficiency in the area of
profession,..................test is conducted
a. Personality Test b. Aptitude Test c. Trade Test d. Intelligence Test
Ans.Trade Test
6. Find the odd one.
a. Leadership b. Communication c. Co-ordination d. Supervision
Ans. Co ordination
7. The role of subordinates of an organisation is enhanced by giving them
more autonomy. This refers to:
a. Delegation b. Decentralisation b. Span of control d. Departmentalisation
Ans. Decentralisation
8. In order to be successful, an organization must change itself according to
the needs of the environment. Which characteristic of management is
highlighted in the statement?
a) Group activity b) Pervasive c) Dynamic d) Multi
dimensional Ans. Dynamic
9. Your Grand Father has retired as the director of a manufacturing company.
At what level of management was he working?
Top level b) Middle Level c) Lower level d) None of these
Ans. Top level
10. Which element / dimension of business environment involve improvement
and innovations which provide new ways of producing goods and services
and new methods and techniques of operating a business?
a='2'
b='3'
c=fun1(a,b)
print(c)
(d) What will be the output if a and b have values as a=[1,2] and b=[9,10]
(i) 22 (ii) 23 (iii) None (iv) [1,2,9,10]
Ans:
1
a- iii b-ii c-ii d-iv e-iv
2
A-ii B-v C-iv D-I E-iii
Answers
1.d 2.a 3.a 4.a 5.b 6.c 7.b 8. C 9.b 10.b 11.b 12.b 13.d 14.d 15.c
i) += ii)import
iii)None iv)or
Answer:ii)import
3. Write the type of tokens of the following
i) _var ii)in
Answer:i)Identifier ii)Keyword
4. Write the names of the modules which are required to use these built-in
functions:- i)randrange() ii)abs()
Answer:i)random ii)math
Answer:UPDATE
1. Which SQL function is used to count the number of rows in a SQL query?
a) COUNT()
b) NUMBER()
c) SUM()
d) COUNT(*)
2. Which SQL keyword is used to retrieve a maximum value?
a) MOST()
b) TOP()
c) MAX()
d) UPPER()
3. With SQL, how do you select all the records from a table named “Persons”
where the value of the column “FirstName” ends with an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’
6
4. With SQL, how can you return all the records from a table named “Persons”
sorted descending by “FirstName”?
a) SELECT * FROM Persons SORT BY ‘FirstName’ DESC
b) SELECT * FROM Persons ORDER FirstName DESC
c) SELECT * FROM Persons SORT ‘FirstName’ DESC
d) SELECT * FROM Persons ORDER BY FirstName DESC
5. Which of the following is not a DDL command?
a) UPDATE
b) TRUNCATE
c) ALTER
d) None of the Mentioned
1. d 2. c 3.c 4. d 5. a 6. a 7. a 8. a 9. a 10. a
4. ALTER is a command.
1. DDL
2. DML
3. TCL
4. DCL
Ans: 1.
Ans: 3.
6. Which of the following command is used to change the rows that already
exist in a table?
1. Insert.
2. Union.
3. Update.
4. Select
Ans: 3.
3. for
4. While
Ans: 4.
a) [‘AB’, ‘CD’].
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’].
c) [‘ab’, ‘cd’].
d) none of the mentioned
Answer : d
9
Explanation: The loop does not terminate as new elements are being added to the list in each
iteration.
2. What arithmetic operators cannot be used with strings ?
a) +
b) *
c) –
d) All of the mentioned
Answer: c
3. Suppose list1 is [1, 3, 2], What is list1 * 2 ?
a) [2, 6, 4].
b) [1, 3, 2, 1, 3].
c) [1, 3, 2, 1, 3, 2] .
D) [1, 3, 2, 3, 2, 1].
Answer : c
Answer: a
Explanation: Functions are defined using the def keyword. After this keyword comes an
identifier name for the function, followed by a pair of parentheses which may enclose some
names of variables, and by the final colon that ends the line. Next follows the block of
statements that are part of this function.
def sayHello():
print('Hello World!') # block belonging to the function
# End of function #
sayHello() # call the function
sayHello() # call the function again
6. The readlines() method returns
a) str
b) a list of lines
c) a list of single characters
10
d) a list of integers
Answer: b
Explanation: Every line is stored in a list and returned.
7. What is the output of the following line of code, if the sys module has already
been imported?
sys.stdout.write("hello world")
a) helloworld
b) hello world10
c) hello world11
d) error
Answer: c
Explanation: The function shown above prints the given string along with the length of the
string. Hence the output of the function shown above will be hello world11.
8. Which of the following cannot be returned by random.randrange(4)?
a) 0
b) 3
c) 2.3
d) none of the mentioned
Answer: c
Explanation: Only integers can be returned
Answer: a
Explanation: The test(i-1,i+j) part of the function keeps calling the function until the base
condition of the function is satisfied.
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
a)[‘ab’,‘cd’]
b)[‘AB’,‘CD’]
c)[None,None]
d) none of the mentioned
Answer: a
Explanation: The function upper() does not modify a string in place, it returns a new
string which isn’t being stored anywhere.
3 Is Python case sensitive when dealing with identifiers?
a) yes
b) no
c) machine dependent
d) none of the
mentioned Ans Answer:a
4 What is the maximum possible length of an identifier?
12
a) 31 characters
b) 63 characters
c) 79 characters
d) none of the
mentioned Ans Answer: d
Explanation: Identifiers can be of any length.
5 Which of the following is invalid?
a) _a = 1
b)___a = 1
c) str___= 1
d) none of the
mentioned Answer: d
Explanation: All the statements will execute successfully but at the cost of reduced
readability.
6 Which of the following is not a keyword?
a) eval
b) assert
c) nonlocal
d) pass
Answer:
a
Explanation: eval can be used as a variable.
7 Which of the following is an invalid statement?
a) abc = 1,000,000
b) a b c = 1000 2000 3000
c) a,b,c = 1000, 2000, 3000
d) a_b_c =
1,000,000 Answer: b
Explanation: Spaces are not allowed in variable names.
8 Which of the following cannot be a variable?
a) init
b) in
c) it
d) on
Answer:
b
Explanation: in is a keyword.
9 Which is the correct operator for power(xy)?
a) X^y
b) X**y
c) X^^y
d) None of the
mentioned Answer: b
Explanation: In python, power operator is x**y i.e. 2**3=8.
10 What is the answer to this expression, 22 % 3 is?
a) 7
b) 1
c) 0
d) 5
Answer:
b
13
Explanation: Modulus operator gives the remainder. So, 22%3 gives the remainder, that
is, 1.
14
1. What is the output of the
following? x = ['ab', 'cd']
for i in x: i.upper()
print(x)
a) [‘ab’, ‘cd’].
b) [‘AB’, ‘CD’].
c) [None, None].
d) none of the mentioned
2. What is the output of the following?
i = 1 while True:
if i%2 == 0: break
print(i) i += 2
a) 1
b) 1 2
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …
3. What is the output of the
following? x = "abcdef"
while i in x:
print(i,
end=" ")
a) a b c d e f
b) abcdef
c) i i i i i i …
d) error
4. Which of the following is the use of
function in python?
a) Functions are reusable pieces of programs
b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the
mentioned Answer:
a
5. To open a file c:\scores.txt for reading, we use
a) infile = open(“c:\scores.txt”, “r”)
b) infile = open(“c:\\scores.txt”, “r”)
c) infile = open(file = “c:\scores.txt”, “r”)
d) infile = open(file = “c:\\
scores.txt”, “r”)
Answer: b
6. Which is the most appropriate definition for recursion?
a) A function that calls itself
b) A function execution instance that calls another execution
instance of the same function
c) A class method that calls another class method
d) An in-built method that is automatically called
7. Process of inserting an element in stack is called
a) Create
15
b) Push
c) Evaluation
d) Pop
8. What is a Firewall in Computer Network?
A. The physical boundary of Network
B. An operating System of Computer Network
C. A system designed to prevent unauthorized access
D. A web browsing Software
9. Following set of commands are executed in shell, what will be the
output?
>>>str="hello"
>>>str[:2]
>>>
a) he
b) lo
c) olleh
d) hello
10.What is the output of the following? x
= 123 for i in x:
print(i)
a) 1 2 3
b) 123
c) error
d) none of the mentioned
17