

MCQOPTIONS
Saved Bookmarks
This section includes 1007 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.
201. |
What is the output of the code shown below? re.split('[a-c]', '0a3B6', re.I) |
A. | Error |
B. | [‘a’, ‘B’] |
C. | [‘0’, ‘3B6’] |
D. | [‘a’] |
Answer» D. [‘a’] | |
202. |
What is the output of the code shown? re.compile('hello', re.X) |
A. | [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] |
B. | re.compile(‘hello’, re.VERBOSE) |
C. | Error |
D. | Junk value |
Answer» C. Error | |
203. |
Which of the following functions results in case insensitive matching? |
A. | re.A |
B. | re.U |
C. | re.I |
D. | re.X |
Answer» D. re.X | |
204. |
What is the output of the code shown? import re re.ASCII |
A. | 8 |
B. | 32 |
C. | 64 |
D. | 256 |
Answer» E. | |
205. |
Which of the following functions clears the regular expression cache? |
A. | re.sub() |
B. | re.pos() |
C. | re.purge() |
D. | re.subn() |
Answer» D. re.subn() | |
206. |
Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match='aaaa'>. |
A. | >>> re.search(‘aaaa’, “alohaaaa”, 0) |
B. | >>> re.match(‘aaaa’, “alohaaaa”, 0) |
C. | >>> re.match(‘aaa’, “alohaaa”, 0) |
D. | >>> re.search(‘aaa’, “alohaaa”, 0) |
Answer» B. >>> re.match(‘aaaa’, “alohaaaa”, 0) | |
207. |
What is the output of the following function? re.findall("hello world", "hello", 1) |
A. | [“hello”] |
B. | [ ] |
C. | hello |
D. | hello world |
Answer» C. hello | |
208. |
What is the output of the line of code shown below? re.split('\W+', 'Hello, hello, hello.') |
A. | [‘Hello’, ‘hello’, ‘hello.’] |
B. | [‘Hello, ‘hello’, ‘hello’] |
C. | [‘Hello’, ‘hello’, ‘hello’, ‘.’] |
D. | [‘Hello’, ‘hello’, ‘hello’, ”] |
Answer» E. | |
209. |
Which of the following will result in an error? |
A. | >>> p = re.compile(“d”) >>> p.search(“door”) |
B. | >>> p = re.escape(‘hello’) |
C. | >>> p = re.subn() |
D. | >>> p = re.purge() |
Answer» D. >>> p = re.purge() | |
210. |
________ matches the start of the string. ________ matches the end of the string. |
A. | ‘^’, ‘$’ |
B. | ‘$’, ‘^’ |
C. | ‘$’, ‘?’ |
D. | ‘?’, ‘^’ |
Answer» B. ‘$’, ‘^’ | |
211. |
The expression a{5} will match _____________ characters with the previous regular expression. |
A. | 5 or less |
B. | exactly 5 |
C. | 5 or more |
D. | exactly 4 |
Answer» C. 5 or more | |
212. |
The character Dot (that is, ‘.’) in the default mode, matches any character other than _____________ |
A. | caret |
B. | ampersand |
C. | percentage symbol |
D. | newline |
Answer» E. | |
213. |
What is the output of the following?
sentence = 'horses are fast'
regex = re.compile('(?P
|
A. | {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’} |
B. | (‘horses’, ‘are’, ‘fast’) |
C. | ‘horses are fast’ |
D. | ‘are’ |
Answer» E. | |
214. |
What is the output of the following?
sentence = 'horses are fast'
regex = re.compile('(?P
|
A. | {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’} |
B. | (‘horses’, ‘are’, ‘fast’) |
C. | horses are fast’ |
D. | ‘are’ |
Answer» C. horses are fast’ | |
215. |
What is the output of the following?
sentence = 'horses are fast'
regex = re.compile('(?P
|
A. | {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’} |
B. | (‘horses’, ‘are’, ‘fast’) |
C. | ‘horses are fast’ |
D. | ‘are’ |
Answer» B. (‘horses’, ‘are’, ‘fast’) | |
216. |
What is the output of the following? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group(2)) |
A. | are’ |
B. | ‘we’ |
C. | humans’ |
D. | ‘we are humans’ |
Answer» D. ‘we are humans’ | |
217. |
What is the output of the following? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.group()) |
A. | (‘we’, ‘are’, ‘humans’) |
B. | (we, are, humans) |
C. | (‘we’, ‘humans’) |
D. | we are humans’ |
Answer» E. | |
218. |
What is the output of the following? sentence = 'we are humans' matched = re.match(r'(.*) (.*?) (.*)', sentence) print(matched.groups()) |
A. | (‘we’, ‘are’, ‘humans’) |
B. | (we, are, humans) |
C. | (‘we’, ‘humans’) |
D. | we are humans’ |
Answer» B. (we, are, humans) | |
219. |
What does the function re.search do? |
A. | matches a pattern at the start of the string |
B. | matches a pattern at any position in the string |
C. | such a function does not exist |
D. | such a function does not exist |
Answer» C. such a function does not exist | |
220. |
What does the function re.match do? |
A. | matches a pattern at the start of the string |
B. | matches a pattern at any position in the string |
C. | such a function does not exist |
D. | none of the mentioned |
Answer» B. matches a pattern at any position in the string | |
221. |
Which of the following creates a pattern object? |
A. | re.create(str) |
B. | re.create(str) |
C. | re.compile(str) |
D. | re.assemble(str) |
Answer» D. re.assemble(str) | |
222. |
Which module in Python supports regular expressions? |
A. | re |
B. | regex |
C. | pyregex |
D. | none of the mentioned |
Answer» B. regex | |
223. |
The copy module uses the ___________________ protocol for shallow and deep copy. |
A. | pickle |
B. | marshal |
C. | shelve |
D. | copyreg |
Answer» B. marshal | |
224. |
The module _______________ is a comparatively faster implementation of the pickle module. |
A. | cPickle |
B. | nPickle |
C. | gPickle |
D. | tPickle |
Answer» B. nPickle | |
225. |
Lambda functions cannot be pickled because: |
A. | Lambda functions only deal with binary values, that is, 0 and 1 |
B. | Lambda functions cannot be called directly |
C. | Lambda functions cannot be identified by the functions of the pickle module |
D. | All lambda functions have the same name, that is, <lambda> |
Answer» E. | |
226. |
If __getstate__() returns _______________ the __setstate__() module will not be called on pickling. |
A. | True value |
B. | False value |
C. | ValueError |
D. | OverflowError |
Answer» C. ValueError | |
227. |
Which of the following cannot be pickled? |
A. | Functions which are defined at the top level of a module with lambda |
B. | Functions which are defined at the top level of a module with def |
C. | Built-in functions which are defined at the top level of a module |
D. | Classes which are defined at the top level of a module |
Answer» B. Functions which are defined at the top level of a module with def | |
228. |
The pickle module defines ______ exceptions and exports _______ classes. |
A. | 2, 3 |
B. | 3, 4 |
C. | 3, 2 |
D. | 4, 3 |
Answer» D. 4, 3 | |
229. |
Which of the following functions raises an error when an unpicklable object is encountered by Pickler? |
A. | pickle.PickleError |
B. | pickle.PicklingError |
C. | pickle.UnpickleError |
D. | pickle.UnpickleError |
Answer» C. pickle.UnpickleError | |
230. |
Which of the following functions can accept more than one positional argument? |
A. | pickle.dumps |
B. | pickle.loads |
C. | pickle.dump |
D. | pickle.load |
Answer» B. pickle.loads | |
231. |
Which of the following functions can be used to find the protocol version of the pickle module currently being used? |
A. | pickle.DEFAULT |
B. | pickle.CURRENT |
C. | pickle.CURRENT_PROTOCOL |
D. | pickle.DEFAULT_PROTOCOL |
Answer» E. | |
232. |
Which of the codes shown below will result in an error? Given that: object = ‘a’ |
A. | >>> pickle.dumps(object) |
B. | >>> pickle.dumps(object, 3) |
C. | >>> pickle.dumps(object, 3, True) |
D. | >>> pickle.dumps(‘a’, 2) |
Answer» D. >>> pickle.dumps(‘a’, 2) | |
233. |
What is the output of the line of code shown below? pickle.HIGHEST_PROTOCOL |
A. | 4 |
B. | 5 |
C. | 3 |
D. | 6 |
Answer» B. 5 | |
234. |
Pick the correct statement regarding pickle and marshal modules. |
A. | The pickle module supports primarily .pyc files whereas marshal module is used to sterilize Python objects |
B. | The pickle module supports primarily .pyc files whereas marshal module is used to sterilize Python objects |
C. | The pickle module cannot be used to sterilize user defined classes and their instances whereas marshal module can be used to perform this task |
D. | The format of sterilization of the pickle module is not guaranteed to be supported across all versions of Python. The marshal module sterilization is compatible across all the versions of Python |
Answer» C. The pickle module cannot be used to sterilize user defined classes and their instances whereas marshal module can be used to perform this task | |
235. |
To sterilize an object hierarchy, the _____________ function must be called. To desterilize a data stream, the ______________ function must be called. |
A. | dumps(), undumps() |
B. | loads(), unloads() |
C. | loads(), dumps() |
D. | dumps(), loads() |
Answer» E. | |
236. |
The process of pickling in Python includes: |
A. | conversion of a list into a datatable |
B. | conversion of a byte stream into Python object hierarchy |
C. | conversion of a Python object hierarchy into byte stream |
D. | conversion of a datatable into a list |
Answer» D. conversion of a datatable into a list | |
237. |
The output shape of the code shown above: import turtle t=turtle.Pen() for i in range(0,6): t.forward(100) t.left(60) |
A. | Hexagon |
B. | Octagon |
C. | Pentagon |
D. | Heptagon |
Answer» B. Octagon | |
238. |
What is the output of the code shown below? import turtle() t=turtle.Pen() t.goto(50,60) t1=t.clone() t1.ycor() |
A. | 0.0 |
B. | 50.0 |
C. | 60.0 |
D. | Error |
Answer» D. Error | |
239. |
The output of the code shown is similar to the alphabet _______________ import turtle t=turtle.Pen() t1=turtle.Pen() t2=turtle.Pen() t.forward(100) t1.forward(100) t2.forward(100) t1.left(90) t1.forward(75) t2.right(90) t2.forward(75) |
A. | X |
B. | N |
C. | T |
D. | M |
Answer» D. M | |
240. |
The output of the following code will result in a shape similar to the alphabet ___________ import turtle t=turtle.Turtle() t1=turtle.Turtle() t.left(45) t1.left(135) t.forward(100) t1.forward(100) |
A. | V |
B. | Inverted V |
C. | X |
D. | T |
Answer» B. Inverted V | |
241. |
What is the output of the following code? import turtle t=turtle.Pen() t.position() (100.00,0.00) t.goto(100,100) t.distance(100,0) |
A. | 0.0 |
B. | Error |
C. | 100.0, 100.0 |
D. | 100.0 |
Answer» E. | |
242. |
What is the output of the code shown below if the system date is 18th June, 2017 (Sunday)? import turtle t=turtle.Pen() t.goto(100,0) t.towards(0,0) |
A. | 0.0 |
B. | 180.0 |
C. | 270.0 |
D. | 360.0 |
Answer» C. 270.0 | |
243. |
The function used to alter the thickness of the pen to ‘x’ units: |
A. | turtle.width(x) |
B. | turtle.span(x) |
C. | turtle.girth(x) |
D. | turtle.thickness(x) |
Answer» B. turtle.span(x) | |
244. |
What is the output of the code shown below? import turtle t=turtle.Pen() t.backward(100) t.penup() t.right(45) t.isdown() |
A. | True |
B. | False |
C. | Yes |
D. | No |
Answer» C. Yes | |
245. |
What is the output of the snippet of code shown below? import turtle t=turtle.Pen t.tilt(75) t.forward(100) |
A. | A straight line of 100 units tiled at 75 degrees from the horizontal |
B. | A straight line of 100 units tilted at 15 degrees from the horizontal |
C. | A straight line of 100 units lying along the horizontal |
D. | Error |
Answer» D. Error | |
246. |
Which of the following functions results in an error? |
A. | turtle.shape(“turtle”) |
B. | turtle.shape(“square”) |
C. | turtle.shape(“triangle”) |
D. | turtle.shape(“rectangle”) |
Answer» E. | |
247. |
What is the output of the code shown? import turtle t=turtle.Pen() t.forward(100) t.left(90) t.clear() t.position() |
A. | 0.00, 90.00 |
B. | 0.00, 0.00 |
C. | 100.00, 90.00 |
D. | 100.00, 100.00 |
Answer» E. | |
248. |
What is the output of the code shown below? import turtle t=turtle.Pen() t.clear() t.isvisible() |
A. | Yes |
B. | True |
C. | No |
D. | False |
Answer» C. No | |
249. |
What is the output of the following code? import turtle t=turtle.Pen() t.right(90) t.forward(100) t.heading() |
A. | 0.0 |
B. | 90.0 |
C. | 270.0 |
D. | 360.0 |
Answer» D. 360.0 | |
250. |
Which of the following functions returns a value in degrees, counterclockwise from the horizontal right? |
A. | heading() |
B. | degrees() |
C. | position() |
D. | window_height() |
Answer» B. degrees() | |