Python 3 Application Programming
Python 3 Application Programming
Select the most correct statement that differentiates a Generator from a Coroutine
pyodbc is an open source Python module that makes accessing ODBC databases simple. State True or False
Django web frame work uses SQLAlchemy as Object relational mapper. State True or False
Which of the following statement is used to open the file C:\Sample.txt in write only mode?
Which of the following module helps in creating a context manager using decorator contextmanager ?
Which of the following methods of a match object, mo, is used to view the grouped portions of match in the form of a tuple
Which of the following methods of a match object, mo, is used to view the named group portions of match in the form of a dic
In a match found by a defined pattern, how to group various portions of a match
v = 'Hello'
def f():
v = 'World'
return v
print(f())
print(v)
What is the output of the following code ?
def inner1():
return x+y
def inner2(z):
return inner1() + z
return inner2
f = outer(10, 25)
print(f(15))
class A:
def __init__(self, x , y):
self.x = x
self.y = y
@property
def z(self):
return self.x + self.y
a = A(10, 15)
b = A('Hello', '!!!')
print(a.z)
print(b.z)
def stringDisplay():
while True:
s = yield
print(s*3)
c = stringDisplay()
c.send('Hi!!')
What is the output of the following code ?
def stringDisplay():
while True:
s = yield
print(s*3)
c = stringDisplay()
next(c)
c.send('Hi!!')
class A(ABC):
@abstractmethod
@classmethod
def m1(self):
print('In class A, Method m1.')
class B(A):
@classmethod
def m1(self):
print('In class B, Method m1.')
b = B()
b.m1()
B.m1()
A.m1()
class A:
@staticmethod
@classmethod
def m1(self):
print('Hello')
A.m1(5)
What is the output of the following code ?
class A:
@staticmethod
def m1(self):
print('Static Method')
@classmethod
def m1(self):
print('Class Method')
A.m1()
class A(ABC):
@abstractmethod
def m1(self):
print('In class A, Method m1.')
class B(A):
@staticmethod
def m1(self):
print('In class B, Method m1.')
b = B()
B.m1(b)
@contextmanager
def context():
print('Entering Context')
yield
print("Exiting Context")
with context():
print('In Context')
What is the output of the following code ?
class A:
@property
def x(self):
return self.__x
@x.setter
def x(self, value):
if not isinstance(value, (int, float)):
raise ValueError('Only Int or float is allowed')
self.__x = value
a = A(7)
a.x = 'George'
print(a.x)
def decorator_func(func):
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
return wrapper
@decorator_func
def square(x):
return x**2
print(square.__name__)
What is the output of the following code ?
return func(*args)
return wrapper
@smart_divide def divide(a, b): return a / b
print(divide(8,0))
def inner1():
return x+y
def inner2():
return x*y
print(f1())
print(f2())
class A:
@staticmethod
def s1(x, y):
return x + y
a = A()
print(a.s2(3, 7))
What is the output of the following code ?
class A:
@property
def x(self):
return self.__x
@x.setter
def x(self, val):
self.__x = val
@x.deleter
def x(self):
del self.__x
a = A(7)
del a.x
print(a.x)
class A:
@classmethod
def getC(self):
print('In Class A, method getC.')
class B(A):
pass
b = B()
B.getC()
b.getC()
open('C:/Sample.txt', 'a')
open(file_name [, access_mode][, buffering])
['', 'bcd', 'fgh', 'j']
TRUE
send
TRUE
TRUE
Decorators can be chained
fetchone
__enter__, __exit__
re.compile(p)
It closes the opened file automatically
cx_Oracle
A list of lines
@temp.setter
?P<group_name>
with
classmethod
World
Hello
50
25
Helo!!!
TypeError
Hi!!Hi!!Hi!!
AttributeError
TypeError
Class Method
Entering Context
In Context
Exiting Context
ValueError
square
wrapper
0.25
oops! cannot divide
None
35
250
21
AttributeError