Skip to content

Python MCQ Questions

0
Answered
0
Correct
0%
Accuracy
Q1 Easy

What is the purpose of the map function?

Q2 Easy

What is one of the most common use of Python's sys library?

Q3 Easy

What is the basic difference between theses two operations in 're' module: match() and search()?

Q4 Easy

What is the correct syntax for instantiating a new object of the type Game?

Q5 Easy

What is the index of the first item in a tuple or list?

Q6 Easy

What is a future statement?

Q7 Easy

What is the method to retrieve the list of all active thread objects?

Q8 Easy

When opening a file, what is the difference between text mode and binary mode?

Q9 Easy

What is the correct syntax for defining a class called Game?

Q10 Easy

What is the correct syntax for calling an instance method on a class named Game?

Q11 Easy

What is a string in Python?

Q12 Easy

What is delegation?

Q13 Easy

What is the result of ("%g" % 74), '7' ?

Q14 Easy

What is the statement that can be used in Python if a statement is required syntactically but the program requires no action?

Q15 Easy

What is the syntax of assertions in Python?

Q16 Easy

What is the correct syntax that will set the variable "var1" to the value "correct" if variable "a" is greater than 1?

Q17 Easy

What is the correct way to run all the doctests in a given file from the command line?

Q18 Easy

What is the correct way to get the exception as variable in except statement?

Q19 Easy

What is the difference between the two methods, "foo is None", and "foo == None", for the purposes of determining if the type of an object is None?

Q20 Easy

What is a package?

Q21 Easy

What is a base case in a recursive function?

Q22 Easy

What is htmllib?

Q23 Easy

Read the following statements:Statement 1: A simple assignment statement binds a name into the current namespace, unless that name has been declared as global.Statement 2: A name declared as global is bound to the global (module-level) namespace.Which of the following is correct?

Q24 Easy

What is used to read the next line in a file up to the '\n'?

Q25 Easy

a = range(1, 10) m = map(lambda x: x % 2 == 0, a) What is the value of m

Q26 Easy

What is a persistent dictionary?

Q27 Easy

What is " __doc__" for in Python?

Q28 Easy

What is the output of the following code?def foo(param1, *param2):print param1print param2def bar(param1, **param2):print param1print param2foo(1,2,3,4,5)bar(1,a=2,b=3)

Q29 Easy

What is the output of the following? t=(1,2,4,3,5) print(t[1:3])

Q30 Easy

What is the correct way to increment the value of the variable "i" by 1?

Q31 Easy

x = reduce(lambda x,y:x+y,[int(x) for x in "1"*10]) What is the value of x?

Q32 Easy

What is the output of the following code? class A(object): def __init__(self): print "Constructor A was called" class B(A): def __init__(self): print "Constructor B was called" class C(B): def __init__(self): super(C,self).__init__() print "Constructor C was called" class D(C): def __init__(self): super(D,self).__init__() print "Constructor D was called" d = D()

Q33 Easy

What is the term used to describe items that may be passed into a function?

Q34 Easy

What is the output of the following script? def f(a, L=[]): L.append(a) return L print(f(1)) print(f(2)) print(f(3))

Q35 Easy

What is the difference between using list comprehensions and generator expressions?

Q36 Easy

What is the runtime complexity of searching for an item in a binary search tree?

Q37 Easy

What is the output of the following code:name = 'Jon'name.rjust(4, 'A')

Q38 Easy

Assume: a = 1 b = 4 c = (a == 'text') and a or b. What is the value of c?

Q39 Easy

What is the result of eval("7"), string.atoi("4"), int("7") ?

Q40 Easy

What is the best way to randomly select an item from list?

Q41 Easy

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?

Q42 Easy

What is the default SimpleHTTPServer port?

Q43 Easy

What is the value of the variable a after the following statement: a=(1,2,3); a=a[2];

Q44 Easy

What is the result of the expression: print [k(1) for k in [lambda x: x + p for p in range(3)]]?

Q45 Easy

What is the purpose of the pass statement in Python?

Q46 Easy

What is the result of the following expression: print((1, 2, 3) < (1, 2, 4))?

Q47 Easy

import itertools p = itertools.permutations([1, 2]) f = filter(lambda x: x[0] % 2 == 0, p) What is the value of f?

Q48 Easy

What is an abstract class?

Q49 Easy

What is key difference between a set and a list?

Q50 Easy

What is the return value of trunc()?

Showing 50 of 127 questions