Signup/Sign In

Python Online Practice Test - 5

This Test will cover complete Python with very important questions, starting off from basics to advanced level.
Q. A group of developers,were discussing the various options,for interacting with websites,through code. Following points were stated -
DevA - While using urllib,one can use the method urlencode,for generation of GET query strings.The Requests module,does the encoding automatically.Urllib2 also has urlencode method.
DevB - Only urllib module, has an urlencode function.Requests module,handles error very well,whereas,the urllib2 raises an URLError,if the authentication fails.
DevC - Both urllib2 and Requests module,raise an URLError,when authentication fails.The urlencode() method,is present in urllib2 and not in urllib module.
Mark the correct statement.
Q. A developer was debugging,a Python program,using the pdb module.Below are some descriptions,of the debug commands:
1) List the source code.
2) Add a breakpoint.
3) Debug step by step.
4) Resume execution.
Match them with their actual command.
Q. A developer was working on Dictionary data structure in Python3. He executed the following code snippets:

#1
City1 = {'Pune': 25,'Benguluru':30,'Delhi':40}
City2 = {'Delhi':38}	
print(cmp(City1,City2))

#2
City1 = {'Pune': 25,'Benguluru':30,'Delhi':40}
del City1{'Pune'}
print(City1)


Mark the correct output.
Q. A developer was solving a worksheet of regex problems. He came across the following:

import re 
print((re.split(r'\s','funday is sunday'))) 
print((re.split(r's','fun is sunday'))) 
print((re.split(r'\d','sunday 3 times a week')))

Mark the correct output of the print statements.

Q. A developer was teaching his team,about the different socket methods,found in network programming.Below are few descriptions of the same:
1) This method,sends the User Datagram Protocol(UDP) message.
2) This method,sends a TCP message.
3) This method,receives a UDP message.
4) This method,starts the TCP listener.
Map them with the actual method names.(s is the socket object).
Q. In an interview,developers were asked to mention if the following statements,were true or false.
1) Static analysis tool, that detects bugs,present in Python code is PyChecker.
2) PyModule tool,checks if the python module,meets the coding standards
3) PyFlakes tool,parses the source files,and,points out various errors,present in the code
4) Pylint,is also a quality checker,which checks the length of each line.
Mark the statements as True or False.
Q. In an exam,following code snippets were provided:

#1
mylist = ['PUNE','MUMBAI','DELHI']
for city in mylist:
	city.lower()	
print(mylist)

#2
print(bool('False'))

#3
statement="Number of continents are "
value = 7
print(statement+value)


Mark the correct output.
Q. A developer had to mark,the following statements,related to Multithreading in Python,as True or False:
1) RLock can be acquired,by the same thread,multiple times.
2) Acquired Lock,can be released,only by the thread,that acquired it.
3) Acquired RLock,can be released by any thread.
4) If an RLock is acquired 'n' number of times, it should be released,'n' number of times.
Mark the correct output.
Q. A developer was trying to parse a XML document in Python code. Mark the correct steps,that, he needs to implement:
1) The xml.dom.minidom module,should be imported, to parse a XML file.
2) The parseXML function,is used to load and parse the XML file.
3) The standard DOM function,getElementsByTagName can be used to get XML tags.
4) The firstChild.name,can be used to print,the name of the firstchild,of the document node.
Mark the correct answer.

Q. Below are mentioned, a few points about different Python frameworks:
1) External libraries are required for database administration and templating
2) Bootstrapping tools are not present
3) Provides flexibility,and,allows the developer, to choose right tools,for their projects.
4) It has built-in modules for routing,authentication and templating.
Guess the name of the framework from the description

Related Tests: