Digital Python Intermediate iON LX Async SP Assessment
Digital Python Intermediate iON LX Async SP Assessment
Question 1
Select the statement which not true about Pythons web development (Choose four)
Question 2
Select the right program for the calculation of factorial: (Choose three)
1. def factorial(N)
res = 1
for i in range(1, N+1):
Res *=1
2. def factorial(N)
In N == 1
Return N
else
Return N * fact0(N-1)
3. def factorial(N)
In N == 1
Return N if N == 1
else
Return N * fact1N-1)#
Question 3
capital_bycapital
3. capitals = {‘United States’: Washington, DC’, ‘France’: ‘Paris’, ‘Italy’: ‘Rome’)
inverted_dict = {}
for key in capitals:
inverted_dict.setdefault(capitals[key], {]).append(key)
inverted_dict
Question 4
Which of the following can be used to invoke the __init__ method in X from Y, where Y is a subclass of X
in (in Python 3.x)?(Chosse two)
1. super().__init__()
2. super().__init__(self)
3. X.__init_(self)
4. X.__init__()
Answer:
1. super().__init__()
3.X.__init_(self)
Question 5
if len(abc) ==1:
item= abc[0]
def f(obj):
rerun obj[item]
else:
def f(obj):
return f
selection = []
print(selection)
1. USTRALIA
2. ALIA
3. STRALIA
4. AU
Answer: STRALIA
Question 6
import sys
try:
f = open(‘textFile.txt’)
s = f.readline()
I = int(s.strip())
Expect IOError as e:
except ValueError:
rasie
except:
finally:
print(“finally excuted…”)
In the code for on ValueError exception there is raise error. Wha is the significance of using ‘raise’.
ValueError exception block?
1. The code will print ValueError print block and exits with an uncaught exception
2. The code will print ValueError print block and exits with an uncaught exception without fianally
bock executed
3. The code will print ValueError print block and exits
4. The code will call except: method and executes the finally block
Question 7
MISSING
Question 8
Which of the following Python?C API functions will NOT always return NULL?
Question 9
What is the output of the following code ? (Output values marked by ??)
??
abc(4,[1,2])
??
abc(10)
??
Question 10
Which two of the following dictionary object return “0” on success and “-1” on failure? (Choose two)
Question 11
Which two techniques can be used to provide polymorphic behavior? (Choose two)
Question 12
class A:
def__ int__(self):
self.calculate(30)
def calculate(self, i)
self.i = 2 *i
class B(A):
def__init__self):
super().__init__()
self.i = 3*i
b = B()
1. “i in Class A is 0”
2. “i in Class A is 60”
3. “i in Class A is 90”
4. Error
Question 13
Question 14
Upon creation of the ‘dumbdbm’ database, files with which of the given extension are created?(Choose
two)
1. .dat
2. .dbm
3. .dir
4. .bin
Question 15
Which of the given tuples are not used in the AF_INER6 address family? (Choose three)
1. groups
2. pid
3. port
4. host
5. sockaddr
Question 16
1. float
2. dictionary
3. set
4. string
Question 17
In Python 3.4, a conventional pluggable event loop model is provided by which of the following library
models?
1. enum
2. asyncio
3. ensurepip
4. selections
Question 18
Question 19
x = “abcdef”
I = “i”
While I in x:
Print(I, end = “ “)
1. Abcdef
2. Error
3. a b c d e f
4. No Output
Question 20
Question 21
Which of the following Python 3.4.2 shell expression will produce the below-given output?
56.25
1. >>> 7.5#2
2. >>> 7.5^2
3. >>> 7.5 ! 2
4. >>> 7.5**2
Question 22
i = [12, 9, 14]
if (j%m == 0):
j = j //2
m=m/j
print(j.m)
else
j=j+m
m=m–j
pring( j, m)
1. 19-12
35-19
46-36
88
19-8
730
21 -7
34 23
2. 19-12
Question 23
For i in ranger(1.6):
if i%4 == 0:
print(‘x’)
elif i%2 == 0:
print(‘x’)
else:
print(‘xxxx’)
1. XXXXX
XX
XXXXX
XX
XXXXX
2. XXXXX
X
XXXXXX
X
XXXXX
Question 24
Question 25
Question 26
Which of the following shell expressions in Python 3.4 will give an error?
>>> unicodedata.category(“A”)
>>> unicodedata.decimal(9)
3. >>>import unicodedata
>>> unicodedata.bidirectional(“\u0660”)
>>> unicdedata.name(“/”)
Answer:
import unicodedata
>>> unicodedata.decimal(9)
Question 27
What is the output of the following code?
Class A:
def__init__(self, x):
self.x = x
x = 44
Print (a.x)
1. Syntax Error
2. 44
3. 4
4. None of the above
Question 28
As part of the development of a Python module you want to store some user information details into
a table for running SQL query. But you don’t have the privilege to install a new database. You have to
use the feature available with default Python installation.
1. Use Dictionary and write a python program interface to interpret SQL query
2. MySQL is available as default builtin Database. This can be directly used
3. Use File and write a python program interface to interpret SQL query
4. SQL is default builtin Database > This can be directly used
Question 29
Question 30
A company uses an offline system orders for selling products. The company wants to build a new online
site. The data trends of the current orders show that customers typically buy once or twice a year. The
company has the following requirements for the site:
What advice would you give this company about the user interface for this application?
1. Write the UI using Ajax accessing Python code
2. Create the UI by mixing HTML and Python code adding libraries
3. Not possible to build such UI requirement in Python
4. Write the UI using Django Framework
Question 31
Select the correct statement about interfacing with other languages from python (Choose four)
Question 32
In which of the following modes of files, the ‘tell()’ functions returns an opaque number that gives the
current position of the file object?
1. binary mode
2. text mode
3. both binary and text modes
Question 33
What will be the output of the following line of code in Python 3.4.2?
1. 0xD0xB0xC
2. 0xD + 0xB + 0xC
3. 0
4. 22
5. 36
Question 34
Which of the following relationship suits best for an Employee and a Person
1. Inheritance
2. Composition
3. None of the above
4. Association
Question 35
Which of the following exceptions is raised when the sequence subscript is out of range?
1. exception UnboundLocalError
2. exception OverflowError
3. exception EOFError
4. exception IndexError
Question 36
1. connect()
2. bind()
3. listen()
4. accept()
Question 37
Which two of the following interface objects cannot have the child nodes? (Choose two)
1. NodeLIst
2. Node
3. ProcessingInstruction
4. Element
5. Comment
Question 38
There is a folder which contains multiple html files. You have to provide a program which will extract the
html keywords from provided files. Select the appropriate Python library which can be used to achieve it.
1. import html.parser
2. import bs4
3. import json
4. import xmltodict
Question 39
Please select the value of after executing the below code. What will be values of var2.
1. [1, 2, 3, 4]
2. Error
3. Var1
4. [1, 2, 3]
Question 40
class A:
self.i = i
class B(A):
self.j= j
def main():
b = B(50)
print(b, i)
print9b, j)
main()
1. 0 50
2. Attribute Error
3. None of the above
Question 41
A user wants to build a ETL in we which should be able to execute the dynamic rules. Which module in
Python can be used for dynamic rule execution?
Question 42
A company wants to analyze the receivable and payable for the last 5 years data to identify the
exceptional data. What are the different python functions available to detect outliers?
1. Using boxplot
2. Using regular expression
3. Using django
4. Using histogram
Question 43
class A:
self.x =x
>a = A(100)
>a.__dict__[‘y’] = 50
>print(a.x + len(a.__dict__))
1. 102
2. 101
3. 150
4. 100
Question 44
What will be the output of the below given code in Python 3.4.2 shell?
>>>str[::-1]
1. example12’
2. 321elpmaxe’
3. Xample123’
4. 3’
Question 45
How do you create a package so that the following reference will work?
p = myxml.objparser.ObjParser()
You are building a subsystem that has several complex components, but you want to hide that
complexity from the client code. Which pattern can you apply to hide this complexity?
1. Proxy
2. Façade
3. Decorator
4. Adaptor
5. Bridge
Question 47
Class A:
def__init__(self):
self.calculate(30)
self.i = 2 * i
Class B(A):
def__init__(self):
super().__init_()
b = B()
1. Error
2. “i in Class B is 90”
3. “i in Class B is 0”
4. “i in Class B is 60”
Question 48
>sum([[2,6],[4,3]],[])
1. [0,0]
2. [6,9]
3. [2,6,4,3]
Question 49
You have been asked to create middleware using Django, Select the correct statements that cab achieved
using middleware (Choose two)
Question 50
sum=sum+sq(i)
def(sq):
return n*n
Question 51
Question 52
class A:
def__init__(self, i = 1):
self.i = i
classB(A):
def__init__(self, j = 2):
self.j= j
def main():
b = B()
print(b.i, b.j)
main()
1. 00
2. 02
3. 01
4. 12
Answer: 4. 1 2
Question 53
What will be output of the following code Snippet. There is no text files called openfile is available
try:
fh = open(“openfile”, “w”)
else:
finally:
fh.close()
1. Program will successfully write the content into openfile and then Print the statement “Close the
file”
2. Raise an exception and in exception “This is Exception” will be printed and the finally block
“Closing the file” will be
3. Fails to Compile
Question 54
You have been given Flight data for analysis. You have to represent the data in graphical representation.
Which are the python library can be used for data visualization? (Choose two)
1. pandas
2. matplotlib
3. scipy
4. pytab
5. ipython
Question 55
Which of the following shell expression will give the result as an integer value?
Question 56
You are given assignment to do sentimental analysis on data available in Web. As part of this exercise
you need write program that need to extract data from the website. Please select the appropriate library
for connecting to the sire and extracting the required data from the webpage (Choose two)
1. Import numpy
2. Import bs4
3. Import django
4. Use urlib
5. Import regex
Question 57
During the execution of the below given Python/C API function, what will happen no exception has been
raised int PyErr-ExceptionMatches(PyObject *exc)
Question 59
A company wants to build a web application to support a non-functional requirement (NFR) to process
all requests within 5 seconds. But the customers are complaining that the systems very slow and you
have been contracted to fix the system. The company is not sure whether its customers are meeting the
NFR. What is the most appropriate course of action?
Question 60
Question 61
While working in Python 3.4 sockets are by default created in the ______________________________
1. non –blocking
2. timeout
3. blocking
Answer: blocking
Question 62
‘-6.34’.zfill(7)
1. -006.34’
2. -6.3400’
3. -6.34’
4. -06.340
Answer: '-6.34'.zfill(7)
Question 63
class A:
def__init__(self, param):
self.a1 = param
class B(A)
def__init__(self, param):
self.b1 = param
obj = B(100)
1. 100 100
2. Error is generated
3. Null Null
4. Null 100
Question 64
You are designing the RDMS access for your current project and deciding which approach is best and
ORM-centric implementation of a client SQL based implementation. Which two statements are
guaranteed to be true in all cased when comparing the two approaches? (Choose two)
1. Any decision must consider and address the issues of performance, scalability, ease of
development, and ACID semantics, weighted according to the specific application being
designed.
2. ORM implementation that do NOT subscribe to an open, standardized API are more difficult to
maintain in the long term
3. ORM is better choice than database connector, because ease of development database
4. Database connector, is a better choice than ORM, because it combines direct access to the
database, a minimal programming model, the best performances and scalability, and ease fo
development
Question 65
What are advantages of JSON over HTTP, as compared to SOAP over HTTP?
https://www.techbeamers.com/online-python-quiz-beginners-classes-objects/
https://liveexample-ppe.pearsoncmg.com/selftest/selftestpy?chapter=12
https://quizack.com/python/mcq/this-question-is-based-on-the-graphic-shown-below-consider-the-
python-code-in-figure-1-of-the-given-image-and-choose-its-correct-output-from-figure-2-0-00-b-0-02-c-
this-question-is-based-on-the-graphic-shown-below-in-python-3-4-2-shell-what-will-be-the-output-of-
the-given-code