Skip to content

Python MCQ Questions

0
Answered
0
Correct
0%
Accuracy
Q51 Easy

What is a DBM in Python?

Q52 Easy

Given a list defined as numbers = [1,2,3,4], what is the value of numbers[-2]?

Q53 Easy

What is the correct syntax for defining a class called Game, if it inherits from a parent class called LogicGame?

Q54 Easy

What is the best way to check if the object 'myobject' is iterable in Python?

Q55 Easy

What is the type of each element in sys.argv ?

Q56 Easy

What is the proper way to define a function?

Q57 Easy

What is the correct syntax for creating a variable that is bound to a dictionary?

Q58 Easy

What is the default encoding in the string function encode()?

Q59 Easy

What is the del statement used for?

Q60 Easy

When running a python script what is sys.argv[0] equal to?

Q61 Easy

What is the purpose of the self keyword when defining or calling methods on an instance of an object?

Q62 Easy

The following lines do the same work. What is the difference between them? lines = string.split(text, '\n') and lines = text.split('\n')

Q63 Easy

What is the purpose of an if/else statement?

Q64 Easy

After executing the following statements, what is the value of var? var = "dlrow olleh" var = var[::-1]

Q65 Easy

What is the result of the following code:>>> import itertools>>> x = itertools.count(0)>>> x.__class__.__name__

Q66 Easy

In a Python 3 class declared as "Child(Base)", what is the correct way for a method "foo()" to call its base implementation?

Q67 Easy

What is the name of a feature invoked by the following: "This is a string"[3:9]

Q68 Easy

What is a correct term for the following piece of Python syntax: 3 + 4

Q69 Easy

What is the algorithmic paradigm of quick sort?

Q70 Easy

What is the correct syntax for creating a vaiable that is bound to a list?

Q71 Easy

What is the most flexible way to call the external command "ls -l" in Python?

Q72 Easy

What is the purpose of the "self" keyword when defining or calling instance methods?

Q73 Easy

What is returned by the following expression: ("123",)[0]

Q74 Easy

After executing the following code, what is the value of d? d = [0] l = lambda x: d.append(x) d.pop() l(1)

Q75 Easy

Consider the following Python code: test = 1/2 What is the value of 'test' in Python 2.7 and 3.5, respectively ?

Q76 Easy

What is a 'docstring'?

Q77 Easy

What is the difference between class attributes and instance attributes?

Q78 Easy

what is a valid way to run asyncio loop.

Q79 Easy

Given the following assignment: s = ('xxx', 'abcxxxabc', 'xyx', 'abc', 'x.x', 'axa', 'axxxxa', 'axxya'), what is the result of the expression filter ((lambda s: re.search(r'xxx', s)), s)?

Q80 Easy

What is the maximum recursion limit in Python?

Q81 Easy

What is the purpose of an 'if' statement?

Q82 Easy

What is the correct form for the first line of the switch operator?

Q83 Easy

A function can be declared using "def double(x): return x+x" or using "double = lambda x: x+x". What is the difference between these declarations?

Q84 Easy

What is the result of print(2 <> 3) in Python 3?

Q85 Easy

If d = set( [ 0, 0, 1, 2, 2, 3, 4] ), what is the value of len(d) ?

Q86 Easy

What is an instance method?

Q87 Easy

What is the main difference between a tuple and a list?

Q88 Easy

What is a variable?

Q89 Easy

What is the output if following code executed? a1 = 0 b2 = 1 c3 = 2 def fru_box(): a1 = b2 + c3 print((a1, '\t', b2, '\t', c3)) return fru_box()

Q90 Easy

What is the type of x? x = 10.0//5

Q91 Easy

What is the difference between using single quotes and double quotes in Python strings?

Q92 Easy

In a Python 2 new-style class declared as "Child(Base)", what is the correct way for a method "foo()" to call its base implementation?

Q93 Easy

What is the result of the following code: listOne = [1, 3, 5] listTwo = [2, 4, 6] listNew = listOne + listTwo print listNew

Q94 Easy

Given array = [1, 2, 3, 4, 5, 6] what is the value of array after the following statement? del array[1:3]

Q95 Easy

What does a function definition header end with?

Q96 Easy

What is the correct way to delete a directory that is not empty using Python?

Q97 Easy

What is a list comprehension?

Q98 Easy

If you want to enter accented characters, what is put in front of the string the character?

Q99 Easy

What is a lambda function ?

Q100 Easy

What is the runtime of accessing a value in a dictionary by using its key?

Showing 100 of 127 questions