Python multiple choice quiz

Python Basic Interview Questions:

Ques. In UNIX, a key-combination is used to quit the python shell.
(a) Control-z
(b) Control-v
(c) Control-d
(d) Control-c

Ans. (c)

Ques. The range(3,7) will give __
(a) [4, 5, 6, 7]
(b) [3, 4, 5, 6, 7]
(c) [3, 4, 5, 6]
(d) 3, 4, 5, 6

Ans. (c)

Ques. Python shell prompt is __
(a) <<<
(b) >>
(c) >
(d) >>>

Ans. (d)

Ques. What is the output of the python program?
z=2-7j
print z.real,z.imag
(a) 2.0 -7.0
(b) 2 7
(c) 2 -7
(d) 2.0 7.0

Ans. (a)

Related: powerpoint quiz answers

Ques. What is the output of the last line of the python program (Interactive mode)
>>>r=2.3
>>>r
2.3
>>> 5+_
(a) 5
(b) 2.3
(c) 3.3
(d) 7.3

Ans. (d)

Ques. What is the output of the python code ’maths’*3
(a) t
(b) maths3
(c) ’mathsmathsmaths’
(d) h

Ans. (c)

Ques. The statement used to read a string quantity as an input from keboard is .
(a) input
(b) read
(c) raw input
(d) scanf

Ans. (c)

Ques. What is the output of the python code ’ma’ ’ths’
(a) ma ths
(b) ’maths’
(c) ’ma”ths’
(d) ’ma’ ’ths’

Ans. (b)

Related: networking exams questions

Ques. x = {”a”: ”1”, ”b”: ”2”, ”c”: ”3”}, then x is a .
(a) dictionary
(b) list
(c) set
(d) array

Ans. (a)

Ques. What is the output of the last line of the python program (Interactive mode)?
>>>word=’maths’
>>>word[2:4]
(a) ’at’
(b) ’aths’
(c) ’ths’
(d) ’th’

Ans. (d)

Ques. What is the output of the last line of the python program (Interactive mode)?
>>>word=’maths’
>>>word[2:]
(a) ’ths’
(b) ’ma’
(c) ’mat’
(d) ’aths’

Ans. (a)

Ques. The while loop statement loop starts with the symbol .
(a) {
(b) ”
(c) ;
(d) :

Ans. (d)

Related: questions on photoshop

Ques. If a is a list, append(3) is equivalent to .
(a) a.3
(b) a+3
(c) a[len(a):] = [3]
(d) [a,3]

Ans. (c)

Ques. What is the output of the last line of the python program (Interactive mode)
>>>word=’maths’
>>>word[:-2]
(a) ’hs’
(b) ’ma’
(c) ’mat’
(d) ’math’

Ans. (c)

Ques. If x is a list, then its 5th element can be accessed using the python command .
(a) x(5)
(b) x[4]
(c) x(4)
(d) x[5]

Ans. (b)

Related: excel quizzes with answers

Ques. What is the output of the last line of the python program (Interactive mode)
>>>x=[’calculus’,10,’algebra’]
>>>x[1]=x[1]+5
>>>x
(a) ’105’
(b) 15
(c) [’calculus’,5,10,’algebra’]
(d) [’calculus’,15,’algebra’]

Ans. (d)

Ques. If x=[1,2,3,’maths’,5.2] is a list, then x[3][1] is .
(a) ’a’
(b) 5
(c) 3
(d) ’maths’

Ans. (a)

Ques. What is the output of the last line of the python program (Interactive mode)
>>>x=[1,2,’cat’,’dog’]
>>>x[0:2]=[]
>>>x
(a) [1,2,’cat’,’dog’]
(b) [1,2]
(c) [’cat’,’dog’]
(d) []

Ans. (c)

Ques. can’nt be a member of a list.
(a) A picture
(b) A number
(c) A list
(d) A string

Ans. (a)

Related: questions on Word

Ques. What is the output of the last line of the python program (Interactive mode)
>>>x=[1,2,’cat’,’dog’]
>>>x[2:2]=[3,4,5]
>>>x
(a) [3, 4, 5]
(b) [1, 2, 3, 4, 5, ’cat’, ’dog’]
(c) [1, 3, 4, 5, ’dog’]
(d) [1, 2, ’cat’, ’dog’]

Ans. (b)

Ques. If a is a list, extend this list by appending all the items in the list L is done by using .
(a) a.L
(b) a.extend(L)
(c) a*L
(d) a.append(L)

Ans. (b)

Ques. What is the output of the last line of the python program (Interactive mode)
>>>x=[1,2,3,4]
>>>x.append(5)
>>>x
(a) [1 ,2 ,3 ,4 ,5]
(b) []
(c) [5 ,1, 2, 3, 4]
(d) [6, 7, 8, 9]

Ans. (a)

Ques. The else if option in the if loop is possible by using the python statement __
(a) elseif
(b) elif
(c) elseif{
(d) else

Ans. (b)

Related: operating system quiz

Ques. The python statement, like in C, continues with the next iteration of the loop.
(a) next
(b) proceed
(c) do
(d) continue

Ans. (d)

Ques. In a list its elemets are enclosed in __
(a) curved brackets
(b) curl brackets
(c) double quotes
(d) square brackets

Ans. (d)

Ques. The python statement can be used when a statement is required syntactically but the program requires no action.
(a) go
(b) pass
(c) skip
(d) next

Ans. (b)

Ques. What is the string command used to get the number of characters of a string?
(a) lenth
(b) size
(c) len
(d) dim

Ans. (c)

Related: travel and tourism quiz

Ques. Defining a function in python, the statement starts with __
(a) def
(b) define
(c) function
(d) function{

Ans. (a)

Ques. What is the output of a.remove(x), where a is a list and x is an element?
(a) Remove all the items from the list whose value is x.
(b) Remove the item whose value is x and among its first appearance in the list.
(c) Remove the last item from the list whose value is x.
(d) Remove all the items from the list.

Ans. (b)

Ques. What is the output of the last line of the python statement (interactive mode)?
>>>args = [1,4,2]
>>>range(*args)
(a) [1, 4]
(b) [1, 4, 2]
(c) [1, 3]
(d) [1, 2]

Ans. (c)

Ques. What is the output of the last line of the python statement (interactive mode)?
>>>x=5
>>>x*=2
>>>x
(a) 12
(b) 2*
(c) 25
(d) 10

Ans. (d)

Related: question on internet

Ques. What is the python expression used to remove the item from a list at the given position in the list, and return it?
(a) remove
(b) removeitem
(c) pop
(d) delete

Ans. (c)

Ques. If L is a list, what the output of del L[2:5].
(a) It gives an error
(b) It returns list which splits at position 2 and 5.
(c) It returns the list in which the the elements from position 2 to position 4 are removed.
(d) It returns the list with position 2 to 5 are empty.

Ans. (c)

Ques. What is the python expression used to return the index in the list L of the first item whose value is x?
(a) L.position(x)
(b) index(L,x)
(c) position(L,x)
(d) L.index(x)

Ans. (d)

Ques. Output of 50 − 2 4/2 is __
(a) 96
(b) 45
(c) 46
(d) 94

Ans. (c)

Related: business analysis mcq

Ques. What is the python expression used to return the number of times x appears in the list L?
(a) L.count(x)
(b) L.times(x)
(c) L.len(x)
(d) count(L,x)

Ans. (a)

Ques. What is the python expression used to sort the items of the list L, in place?
(a) L.arrange(x)
(b) L.sort()
(c) sort(L)
(d) arrange(L,x)

Ans. (b)

Ques. Tuples consist of a number of values separated by __
(a) semicolon
(b) space
(c) comma
(d) colon

Ans. (c)

Ques. Using the symbol, we commend the line in python coding.
(a) #
(b) %
(c) !
(d) ?

Ans. (a)

Related: cyber security quiz questions

Ques. What is the output of this python statement (interactive mode).
>>> for i in reversed(xrange(1,10,2)):
… print i+1,

(a) 10 8 6 4 2
(b) 1 3 5 7 9
(c) 1, 10, 2
(d) 9 7 5 3 1

Ans. (a)

Ques. If a = set(’mathematics’), then a is
(a) set(’mathematics’)
(b) set([’a’, ’c’, ’e’, ’i’, ’h’, ’m’, ’s’, ’t’])
(c) set([’m’, ’a’, ’t’, ’h’, ’e’, ’m’, ’a’, ’t’, ’i’, ’c’, ’s’])
(d) set(’matheics’)

Ans. (b)

Ques. sys is a __
(a) python variable
(b) python system
(c) python module
(d) system

Ans. (d)

Ques. numpy is a python module. What is the command to use all the functions available in this module?
(a) numpy import
(b) from numpy import *
(c) use numpy
(d) call numpy

Ans. (b)

About the author

Deepika

Deepika is a computer teacher who has been teaching computers to school and college kids for several years. In addition to her teaching duties, Deepika shares her knowledge of computers through her quizzes.

error: Content is protected !!